JSON Formatter and Validator

Paste JSON to check that it is valid and make it readable. The formatter re-indents it with two or four spaces, or minifies it to a single line for sending in a request. If the JSON is broken, you see the error reported by your browser’s JSON parser, with the line and column where your browser provides them.

Text

Loading tool…

At a glance

Input
Any JSON text
Output styles
2-space, 4-space or minified
Validation
Uses the browser’s JSON.parse; errors show its message and, where available, line and column
Not supported
Comments, trailing commas and single-quoted strings (they are not valid JSON)

How it works

  1. Paste JSON

    Paste an API response, config file or any JSON text.

  2. Choose a style

    Formatted with 2 or 4 spaces, or minified to one line.

  3. Copy the result

    Copy the formatted output, or fix the error shown.

Which developer tool do you need?

JSON often travels with other encodings.

OptionBest forTrade-off
JSON Formatter (this page)Validating and reading JSON.Strict JSON only.
Base64 Encode and DecodeJSON that arrives Base64-encoded, as in tokens.Decode first, then format.
URL Encode and DecodeJSON passed in a query string.Decode first, then format.
Text CompareSpotting changes between two JSON versions.Format both first for clean line diffs.
Epoch ConverterReading timestamps found in the JSON.One value at a time.

Example: finding a broken comma

A config file fails to load and you suspect a typing mistake.

  1. Paste the file. The status shows an error and, in many browsers, the line and column.
  2. Look at that position: a common cause is a comma after the last item in an object.
  3. Remove it; the status changes to Valid JSON and the formatted result appears.
  4. Choose Minified to get a single line for a request body.

When to use JSON Formatter and Validator

Use it when an API response is a single unreadable line, when a config file refuses to load, when you need compact JSON for a request, or when you want to confirm that a file is valid before sharing it. Because nothing is uploaded, it is safe for tokens and personal data.

What makes JSON valid

Keys and strings must use double quotes, items are separated by commas with none after the last item, and only objects, arrays, strings, numbers, true, false and null are allowed. Anything else, including comments, makes the whole document invalid.

Formatting does not change data

Pretty-printing and minifying only change spaces and line breaks. The values are the same, except that very large numbers are limited by JavaScript’s number precision, as noted above.

Safe for secrets

API responses often contain tokens and personal data. Because this formatter runs in your browser and does not send the text anywhere, it avoids pasting secrets into an online service that stores them.

JSON and APIs

Most web APIs send and receive JSON. When a request fails, formatting the body you are sending and the response you receive is usually the quickest way to spot a missing field, a wrong type or a value in the wrong place.

JSON and configuration files

Many tools store settings in JSON, such as package.json in JavaScript projects and settings files in code editors. A single misplaced comma can stop a program from starting. Formatting the file shows its structure clearly, making it easy to see which bracket closes which section.

Minified JSON in transit

APIs usually send JSON without spaces to save bandwidth, which is why responses arrive as one long line. Formatting changes nothing about the data; it only makes the structure easy for people to read.

If something looks wrong

It says invalid but the file works in my app
Your app may accept JSON5 or comments. Strict JSON does not allow comments, trailing commas or single quotes.
No line number is shown
Some browsers report only a message. Look for the token named in the message, such as an unexpected }.
Large numbers change
JSON numbers beyond about 15 significant digits lose precision in JavaScript. Keep long IDs as strings.
The page slows down
Very large files of many megabytes take longer to format in a text box. Format a smaller part if possible.

Common questions

Can I format JSON with comments?

Remove the comments first; standard JSON does not allow them.

Can I download the result?

Copy it from the result box and save it in your editor.

Does it validate against a schema?

No. It checks syntax only.

Is my JSON sent to a server?

No. Parsing and formatting use the JSON functions built into your browser.

Does it fix invalid JSON?

No. It reports where parsing failed so you can fix it. Common causes are trailing commas, single quotes and missing quotes around keys.

Are keys sorted?

No. Keys keep their original order.

JSON is parsed by your browser’s own parser, so API responses, tokens and personal data are never uploaded.