Skip to content

JSON formatter and validator.

Format, validate and minify JSON with exact error locations. Big numbers and duplicate keys stay exactly as you wrote them.

Output

Valid JSON

120 B → 158 B
Status
Valid
Size
120 B
158 B formatted
Keys
6
Max depth
2

Free and private: this tool runs entirely in your browser.Need a fast website or web app? Talk to TechnoHelp

How to use the JSON formatter

  1. Paste your JSON

    Paste JSON from an API response, config file or log. It is checked as you type, so you see whether it is valid right away.

  2. Fix any errors

    If the JSON is invalid, the tool shows the line and column, explains the problem and points at the exact character. Click Show in input to jump there.

  3. Choose the output

    Indent with 2 spaces, 4 spaces or tabs, or minify it to a single line. Turn on Sort keys to order object keys A to Z at every level.

  4. Copy or download

    Click Copy JSON, press Ctrl / ⌘ + Enter, or download a .json file. The stats show the size before and after, the number of keys and the nesting depth.

Common JSON errors and how to fix them.

Most invalid JSON is JavaScript-style syntax that the stricter JSON grammar doesn’t allow.

ErrorInvalidValid
Trailing comma{"a": 1,}{"a": 1}
Single quotes{'a': 'b'}{"a": "b"}
Unquoted key{a: 1}{"a": 1}
Missing comma{"a": 1 "b": 2}{"a": 1, "b": 2}
Comment{"a": 1 /* note */}{"a": 1}
NaN, Infinity or undefined{"a": NaN}{"a": null}
Leading zero{"zip": 02134}{"zip": "02134"}
Unescaped backslash"C:\Users\ada""C:\\Users\\ada"
Line break in a string"line one↵line two""line one\nline two"
Capitalized literal{"ok": True}{"ok": true}

The full grammar is short and worth a read: see RFC 8259 or ECMA-404, which define the same JSON syntax.

JSON vs JavaScript object syntax.

JSON looks like a JavaScript object literal, but it is a data format with a much smaller set of rules.

Keys
JavaScript: Bare names, or quoted with ' or "
JSON: Always strings in double quotes
Strings
JavaScript: 'single', "double" or `template`
JSON: "Double quotes" only
Trailing commas
JavaScript: Allowed
JSON: Not allowed
Comments
JavaScript: // and /* */
JSON: Not allowed
Values
JavaScript: Any expression: functions, undefined, NaN, Infinity, dates
JSON: String, number, object, array, true, false or null
Numbers
JavaScript: 0x1F, .5, 5., 1_000 and more
JSON: Decimal only, no leading zeros or + sign

In JavaScript, JSON.stringify converts an object to valid JSON: it drops properties whose value is undefined or a function, and writes NaN and Infinity as null. Paste its output here to check it.

Why big numbers change in some tools.

JSON has no limit on number size or precision, but many programs read every number as a 64-bit float.

JSON.parse('{"id": 12345678901234567890}').id
// → 12345678901234567000

RFC 8259 warns that only integers between −(253 − 1) and 253 − 1 are safe across implementations. JavaScript calls that limit Number.MAX_SAFE_INTEGER (9007199254740991). Formatters that parse with JSON.parse and print with JSON.stringify round larger numbers, turn 1.0 into 1 and drop duplicate keys.

This formatter reads the JSON itself and writes every number and string exactly as it appeared. If you design the API, send long IDs as strings so every client reads them the same way.

Frequently asked questions.

How do I format or minify JSON?

Paste your JSON into the input. Choose 2 spaces, 4 spaces or Tab to pretty-print it with indentation, or Minify to remove all whitespace and put it on one line. Then copy the result or download it as a .json file.

How do I find the error in invalid JSON?

The validator checks your JSON as you type and shows the line and column of the first error, a plain-English explanation and a pointer to the exact character. Fix that error and the next one, if any, appears.

Why is a trailing comma invalid in JSON?

The JSON grammar in RFC 8259 only allows commas between values, never after the last one. JavaScript and many other languages accept trailing commas in their own syntax, which is why they often end up in JSON by mistake.

Can JSON have comments?

No. Standard JSON has no comment syntax, so parsers like JSON.parse reject // and /* */ comments. Some tools accept relaxed variants such as JSON with Comments (JSONC) or JSON5, but that text is not valid JSON.

Does JSON allow single quotes?

No. Strings and object keys in JSON must use double quotes. Replace 'text' with "text". A single quote inside a double-quoted string is fine and needs no escaping.

Are duplicate keys allowed in JSON?

RFC 8259 says the names in an object should be unique. When they are not, behavior depends on the parser, and many keep only the last value. This tool keeps every key in the output and warns you about duplicates so you can decide which to keep.

Does sorting keys change my data?

Sort keys only reorders the properties inside objects; values and array order stay the same. JSON objects are unordered by definition, but some programs and diffs do depend on key order, so sorting is off by default.

Is my JSON sent to a server?

No. Formatting and validation run entirely in your browser, and nothing you paste is uploaded or stored. You can use the tool for API responses and config files that contain private data.

From the team behind these tools

Building an API or a web app?

TechnoHelp is an independent web design and development studio. We build fast, secure and scalable websites and web apps on a modern stack.

More free tools.

See all tools