JSON Formatter & Validator

Check that JSON is valid, then pretty-print it with 2 spaces, 4 spaces or tabs, or minify it to one line. Errors show the browser’s parser message, with line and column where available.

Last updated
113 chars

About the JSON Formatter & Validator

API responses, log entries and configuration exports often arrive as one long line of JSON. Paste it here and click Format / Beautify to see one key per line with nested objects indented, or click Minify to squeeze readable JSON back onto a single line for a request body or an environment variable.

Both buttons first parse your input with the browser’s built-in JSON parser, so they double as a validator. If the JSON is broken, the output panel turns red and shows the parser’s message, such as Expected ',' or '}' after property value. When the browser reports only a character position, the tool converts it into a line and column so you can go straight to the problem. The usual culprits are trailing commas, single quotes, unquoted keys and comments, none of which JSON allows.

Because the data passes through a JavaScript parse, two details are normalised: if a key appears twice in one object, only the last value is kept, and integers larger than JavaScript can store exactly (above 9,007,199,254,740,991) are rounded. The tool warns you when it finds such a number, which usually means a database ID that should be sent as a string.

When the JSON is valid, you can take it further: turn an array of records into a spreadsheet with JSON to CSV, or into configuration syntax with JSON to YAML.

How to use the JSON Formatter & Validator

  1. 1

    Paste your JSON

    Replace the sample in the Input JSON box.

  2. 2

    Pick an indent

    Choose 2 spaces, 4 spaces or Tab from the Indent menu. It applies to Format / Beautify.

  3. 3

    Format or minify

    Click Format / Beautify for indented output, or Minify for a single line.

  4. 4

    Fix any error

    If the Output panel shows Invalid, read the message and position, correct the input and click again.

  5. 5

    Copy the result

    Click Copy above the output.

What it can do

Validation on every run

The input is parsed before any output is produced, so you never copy JSON that only looks formatted.

Error positions

The browser’s error message, with a line and column added when only a character position is given.

Three indent styles

2 spaces, 4 spaces or a real tab character.

One-click minify

Removes all whitespace between tokens and leaves the text inside strings exactly as it was.

Large-number warning

Flags integers that lose precision in JavaScript, so IDs don’t change without you noticing.

Limitations

  • There is no tree view, search or key sorting; the output is plain text.
  • Strict JSON only: JSON5, comments, trailing commas and single-quoted strings are reported as errors, not fixed.
  • Duplicate keys are not reported; only the last value is kept.
  • Error wording and detail vary between Chrome, Firefox and Safari, because each browser has its own JSON parser.
  • Very large files are limited by your device’s memory and can make the page slow.

Privacy

Your JSON is parsed and formatted by JavaScript in your browser; nothing you paste is uploaded to FlexyPdf.

Frequently asked questions

Why does my JSON say Invalid when it works in JavaScript?

JavaScript object literals are more forgiving than JSON. JSON requires double quotes around every key and string and doesn’t allow trailing commas, comments, undefined, NaN or functions. Replace those and it should validate.

Why did a long number change after formatting?

JSON is parsed into JavaScript numbers, which hold whole numbers exactly only up to 9,007,199,254,740,991. Longer integers, such as 64-bit IDs, are rounded. Store them as strings if they must stay exact; the tool shows a warning when it finds one.

Does minifying change my data?

No. It removes only the spaces and line breaks between keys, values and brackets. Text inside strings, including its spaces, is unchanged. The only exceptions are the duplicate-key and large-number cases described above.

Can I format JSON Lines (one object per line)?

Not as a whole file, because JSON Lines is not a single JSON value. Format one line at a time, or wrap the lines in square brackets with commas between them to format them as an array.

Which indent should I use?

Two spaces is the most common choice for JSON in APIs and config files and keeps deep nesting compact. Use 4 spaces or tabs to match an existing project’s style.

Ratings & Reviews

—
No ratings yet
5
0
4
0
3
0
2
0
1
0

Rate JSON Formatter & Validator

Help others by sharing your experience. Your rating is shown without your name.

0/600