UltConvert

JSON Formatter and Validator

Paste JSON on the left to see it indented, minified or sorted on the right. If something is wrong, the status line names the line and column where parsing stopped.

Valid JSON · 7 keys · depth 2 · 185 bytes

JSON
Also called JavaScript Object Notation · RFC 8259 · ECMA-404
A plain-text format for structured data made of objects, arrays, strings, numbers, booleans and null. It is what most web APIs send and many config files use, and every major programming language can read it.

What the formatter does with your text

The tool reads your input with the same strict parser your browser uses for web APIs. If the text is valid, it writes it back out with the indent you choose: two spaces, four spaces or tabs. Minify does the reverse and puts everything on one line. Sorting orders the keys of every object alphabetically, which makes two versions of a config file much easier to compare.

If the text is not valid, nothing is rewritten. The status line shows the parser's message and, where the browser reports it, the line and column of the problem, so you can jump straight to it in the input pane.

JSON rules at a glance

ValueWritten asRule
Object{"id": 7, "tags": []}Keys are always strings in double quotes; pairs are separated by commas, with none after the last pair.
Array[1, "two", null]An ordered list that may mix value types. A trailing comma before ] is an error.
String"line one\nline two"Double quotes only. Line breaks, tabs and quotes inside must be escaped with a backslash.
Number-12.5e3Decimal only: no leading zeros, no hex, and no NaN or Infinity.
BooleantrueLowercase true or false, without quotes.
NullnullLowercase and unquoted. undefined is not a JSON value.
Grammar from RFC 8259 and ECMA-404, the two documents that define JSON.

The grammar is small on purpose, which is why JSON travels so well between systems. RFC 8259 also asks that JSON exchanged between systems be encoded as UTF-8 and that the names inside one object be unique. Duplicate keys are not a syntax error, but different parsers handle them differently, so the formatter keeps only the last value, as browsers do.

Errors you will see most often

What you see: Unexpected token or Expected double-quoted property name just before a ] or }.
What to do: Look for a trailing comma after the last item and delete it.
What you see: Expected property name at a key written in single quotes.
What to do: Replace single quotes with double quotes, and put quotes around every key.
What you see: Unexpected end of JSON input.
What to do: A bracket or brace is missing, often because the text was cut off when copying. Paste the whole response again.
What you see: Bad control character in string.
What to do: A raw line break or tab sits inside a string. Write it as \n or \t instead.

Formatted, minified or sorted

Indented JSON is for people: use it when reading an API response, reviewing a config change or pasting an example into documentation. Minified JSON is for machines, where every byte of a request or an environment variable counts. Sorted keys help when you want to compare two files line by line, because the same keys end up on the same lines.

To turn JSON into a page or a spreadsheet rather than tidy it, use JSON to HTML or the data converter.

JSON formatter questions

Is my JSON uploaded anywhere?

No. The page parses and formats the text with your browser's built-in JSON engine, so API keys or customer data in what you paste never leave your device.

Why does the formatter reject comments?

Standard JSON has no comments. Formats such as JSONC or JSON5 allow them, but a strict parser, including this one, stops at the first // or /*.

Does sorting the keys change my data?

Not its meaning: JSON objects are unordered, so {"b":1,"a":2} and {"a":2,"b":1} describe the same thing. Arrays keep their order, because order is part of an array's value.

What does minify do?

It removes every space and line break that is not inside a string. The data stays identical and the text gets smaller, which suits config values and network payloads.

Why are large numbers changed after formatting?

JavaScript stores numbers as 64-bit floating point, so integers above 9,007,199,254,740,991 lose precision when parsed. Keep long IDs as strings if they must stay exact.