Skip to content
EveryFix

JSON Formatter

The JSON Formatter beautifies, validates, and minifies JSON. Paste your data to pretty-print it with your choice of indentation, catch syntax errors with a clear message, or minify it for production — all processed locally in your browser. It's built for everyday developer tasks like untangling a deeply nested API response or double-checking that hand-written JSON is syntactically valid before pasting it into a request body. Because it relies on the browser's strict, standards-compliant JSON.parse, it won't accept looser dialects like JSON5 or JSONC — comments and trailing commas are flagged as errors rather than silently stripped.

Beginner⏱ 30 secondsUpdated 2026-07-08
Valid JSON
{
  "name": "EveryFix",
  "tools": 109,
  "free": true,
  "tags": [
    "fast",
    "private"
  ]
}

Formats, minifies, and validates JSON instantly in your browser — your data is never uploaded. Choose an indent style, or Minify to strip whitespace for production.

How This Tool Works

Paste JSON into the box and it is formatted and validated as you type. Pick 2 spaces, 4 spaces, tabs, or Minify, and copy the result. Invalid JSON shows a clear error so you can fix it.

Formula & Method

The tool parses your input with the browser’s native JSON engine. If it is valid, it re-serializes it with your chosen indentation (or with no whitespace to minify); if it is invalid, it reports the exact syntax error.

Example Calculation

Paste a compact API response, choose 2-space indentation, and it expands into clean, readable JSON — or switch to Minify to collapse it back to a single line for production. Paste {"user":{"id":42,"name":"Alex","roles":["admin","editor"]}} with a trailing comma after "editor"] left in by mistake, and the tool immediately flags the syntax error instead of silently formatting broken JSON.

Please note: This calculator provides estimates for general informational purposes only. Results may not be accurate for every situation — use your judgment and consult a relevant professional when it matters.

About the JSON Formatter

A JSON formatter solves a small but constant problem: data that machines exchange is usually squeezed onto one line, and a human cannot read it that way. APIs, configuration files, log entries, and browser storage all use JSON (JavaScript Object Notation), and a response of a few hundred characters with no line breaks hides its structure completely. Paste it into this tool and it comes back indented, with each key on its own line and nested objects and arrays stepped inward, so you can see at a glance what contains what.

The same pass doubles as a validator. JSON is strict: keys and strings need double quotes, there are no comments, and a stray comma at the end of a list makes the whole document invalid. The tool hands your text to the browser's own JSON parser, so if the text is not valid JSON you get the parser's error message in a red box instead of formatted output. That makes it a quick way to confirm that a hand-edited config file or a request body will be accepted before you send it anywhere.

Developers, QA testers, data analysts, and support staff who copy API responses into tickets all benefit, as does anyone editing a settings file by hand. Because parsing happens locally, you can safely paste internal payloads. One thing worth knowing up front: formatting is a parse followed by a rewrite, not a text-level tidy. The output is a faithful re-serialization of the data, which is usually what you want, but it can differ from your original in a few small ways described in the results guide below.

When to Use It

Reading an API response

You call a REST endpoint with curl or a browser tab and get back 4,000 characters on a single line. Paste it, choose 2 spaces, and the nesting becomes visible. You can now spot that the field you wanted sits under "data.items[0].attributes" rather than at the top level, and copy the readable version into a bug report for a teammate.

Checking a config file before deploy

Tools such as package managers, linters, and cloud consoles reject a config file if one comma is wrong, often with a vague message. Paste the file here first. A trailing comma, a single-quoted key, or a missing closing brace is reported immediately, so you fix it in seconds instead of waiting for a failed build or restart.

Shrinking a payload for production

Pretty-printed JSON is friendlier to read but larger on the wire. Before embedding a sample document in a script, a URL parameter, or a test fixture, switch Style to Minify to strip every optional space and line break. You get the smallest valid form of the same data and can paste it into a single line of code.

Documenting examples for a team

Technical writers and support engineers often need a clean sample request for a wiki page or an email. Paste the raw capture, pick 4 spaces or tabs to match your house style, and copy the result. Consistent indentation makes diffs in version control easier to review, because only real changes show up as changed lines.

How to Use It, Step by Step

  1. Copy the JSON from wherever it lives: a network tab in your browser's developer tools, a curl response, a log file, or a config file. Include the outermost brace or bracket.
  2. Select all of the sample text already in the box labeled "Paste your JSON" and paste over it. Leftover sample characters after your paste cause a confusing syntax error at the very end.
  3. Look just below the box. A green "Valid JSON" label above a dark output panel means the text parsed. A red "Invalid JSON:" message means it did not, and the message usually names the unexpected character or the position where parsing stopped.
  4. Open the "Style" menu at the top right and choose 2 spaces, 4 spaces, Tabs, or Minify. The output updates immediately, so you can switch between styles and compare without pressing a button.
  5. Scroll the output panel if the document is long, and check that the structure matches what you expected, especially the number of items in each array.
  6. Press "Copy" above the output panel. It briefly reads "Copied!" and the formatted or minified text is on your clipboard, ready to paste into your editor, ticket, or request body.
  7. If you hit an error, fix the problem in the input box and the result recalculates as you type. The input is never rewritten for you, so your fixes stay under your control.

Understanding Your Results

The green "Valid JSON" label means the browser's parser accepted your text as strict JSON, which is the standard defined in RFC 8259. It tells you the syntax is correct; it does not tell you the data is correct. A document can be perfectly valid and still have a misspelled key or a number where a string was expected. For that you need a schema check or a look at the application that consumes it. If the label is missing and the output panel is empty, the red error box is telling you why.

The output is regenerated from the parsed data, so a few details can differ from your input. Insignificant whitespace is normalized. Numbers are rewritten in JavaScript's shortest form, so 10.50 becomes 10.5, 1.0 becomes 1, and 1e3 becomes 1000. Integers larger than 9,007,199,254,740,991 lose precision because they are held as 64-bit floating-point values. Object keys that look like whole numbers, such as "2" and "10", are moved to the front in ascending order, ahead of other keys.

When a key appears twice in the same object, only the last value survives in the output, and the earlier one disappears without a warning. A quick sanity check is to compare the number of lines or items you expected against what you see. If you are formatting a file that matters, keep the original, treat the output as a readable view, and use the minified form only when you have confirmed that nothing meaningful was lost in the rewrite.

More Worked Examples

Pretty-print a server config with 4-space indentation

Scenario: Input: {"server":{"host":"localhost","port":8080},"debug":false,"origins":["a.example","b.example"]}. Style set to 4 spaces.

The input is 93 characters on one line. It parses cleanly, so the green "Valid JSON" label appears. With 4 spaces the output has 11 lines: "server" opens an object holding "host" and "port", "debug" sits at the top level with the value false, and "origins" opens an array with one string per line. Switching to 2 spaces gives 134 characters of output, Tabs gives 121, and Minify returns exactly the original 93 characters, since the input had no spare whitespace.

Find a trailing comma that breaks a document

Scenario: Input: {"items":[1,2,3,],"ok":true}. Style set to 2 spaces.

The comma after the 3 is not allowed in strict JSON. Instead of output, the red box appears. In a Chromium-based browser the text reads along the lines of Unexpected token ']' and quotes a snippet of your input around the problem; other browsers word it differently. Delete the comma so the array reads [1,2,3] and the red box disappears. The result is then a valid document in which "items" lists 1, 2, and 3 on separate lines and "ok" is true.

Watch precision and key order change

Scenario: Input: {"id": 12345678901234567890, "price": 10.50, "10": "x", "2": "y", "name": "Zed"}. Style set to Minify.

The minified result is {"2":"y","10":"x","id":12345678901234567000,"price":10.5,"name":"Zed"}. Three things changed. The long id was rounded to 12345678901234567000 because it exceeds what a double-precision number can hold exactly. The price 10.50 became 10.5. The whole-number keys "2" and "10" jumped to the front, in numeric order, while the other keys stayed in their original sequence. If that id is an identifier, store it as a string in your source data.

Tips for Better Results

  • Always select all text in the input box before pasting a new document, because the tool begins with a sample object and any leftover characters after your paste will cause a confusing syntax error at the very end.
  • If your data contains very large identifiers, such as 64-bit database IDs or snowflake IDs, make sure they are quoted strings in the source. A bare number above nine quadrillion is silently rounded by this tool and by JavaScript in general.
  • Use the error position as a map. When a message gives a position number, count characters from the start of the text, and remember that a problem like a missing comma is usually reported at the token after the gap, not at the gap itself.
  • To compare two JSON documents, format both with the same Style setting first so a diff tool shows real differences instead of whitespace noise.
  • Pick Tabs for files that already use tab indentation, and Minify for a URL parameter, a single-line log entry, or an environment variable.
  • When a file contains comments or trailing commas on purpose, as many editor settings files do, remove them first. That format is JSONC or JSON5, and this tool accepts strict JSON only, so the error is expected rather than a bug.

Common Mistakes to Avoid

  • Pasting a JavaScript object literal and expecting it to pass. Unquoted keys like {name: 1} and single-quoted strings are legal in JavaScript but not in JSON, so add double quotes around every key and string value.
  • Leaving a trailing comma after the last item in an object or array, which is the single most common cause of an invalid document. Remove the comma after the final element.
  • Treating a copied log line as JSON when it has a prefix such as a timestamp or a label before the opening brace. Delete everything before the first { or [ and anything after the matching closing character.
  • Assuming the output is a byte-for-byte copy of the input. Numbers are renormalized, duplicate keys collapse, and whole-number keys are reordered, so do not use the output for a signature or checksum computed over the original text.
  • Using NaN, Infinity, undefined, or a date literal as a value. None of these exist in JSON; use null, a string, or an ISO 8601 date string such as "2025-03-14T09:30:00Z" instead.

Assumptions and Limits

  • Validation is whatever the browser's built-in JSON parser does, so it follows the strict JSON standard. Error wording and the exact position reported differ between Chrome, Firefox, and Safari, and between browser versions, even for the same invalid text.
  • The tool checks syntax only. It cannot tell whether field names, types, or required properties match what an API or schema expects, so valid output is not proof that a server will accept the payload.
  • Output is re-serialized from parsed data. Numbers use JavaScript's number formatting and integers beyond 2^53 lose exactness, duplicate keys keep only the last value, and negative zero is written as 0. Treat the result as a readable equivalent rather than an exact copy.

Key Terms

JSON
JavaScript Object Notation, a text format for structured data built from objects, arrays, strings, numbers, true, false, and null. It is language-independent and the most common format for web APIs.
Parse
To read text and turn it into structured data in memory. If the text breaks the format's rules, parsing fails and reports an error.
Serialize
To convert an in-memory value back into text. This tool parses your JSON and then serializes it again with the indentation you chose, which is why numbers and key order can be normalized.
Minify
To remove all optional whitespace from a document so it takes the fewest characters possible without changing the data it represents.
Trailing comma
A comma placed after the last element of an array or object. It is allowed in many programming languages and in JSONC, but strict JSON forbids it.

Frequently Asked Questions

Is my JSON data private?+

Yes. Everything is parsed and formatted in your own browser — your JSON is never uploaded to or stored on any server.

Why does it say my JSON is invalid?+

The tool uses a strict JSON parser, so common issues like trailing commas, single quotes, or unquoted keys will flag an error. The message points to where the problem is.

Can it minify JSON too?+

Yes — choose “Minify” to strip all whitespace and produce the smallest valid JSON, which is handy for production or APIs.

Does it support JSON5 or JSONC (comments, trailing commas)?+

No — the formatter validates against strict JSON (RFC 8259), so comments, trailing commas, and unquoted keys will all trigger an error rather than being silently accepted. Strip those out first if your file relies on those looser features.

Is there a size limit on how much JSON I can paste?+

There's no hard-coded limit, and since parsing runs locally with your browser's native JSON engine, it can typically handle files well into the multi-megabyte range without issue.

What is the difference between JSON and a JavaScript object?+

JSON is a text format; a JavaScript object is a live value in memory. JSON is deliberately stricter: every key must be a double-quoted string, strings cannot use single quotes, and there are no functions, comments, undefined values, or trailing commas. Most JSON text looks like a JavaScript object literal, which is why they get confused, but pasting a JavaScript literal here will usually produce an error until the quoting is fixed.

Why did a big number change after I formatted my JSON?+

The browser stores every JSON number as a 64-bit floating-point value, which represents whole numbers exactly only up to 9,007,199,254,740,991. A longer integer such as 12345678901234567890 is rounded to the nearest value that can be represented and written back as 12345678901234567000. If the number is an ID, keep it in quotes in your source so it is treated as text.

Does formatting change the order of my keys?+

Mostly no, with one notable exception. Keys are written in the order they appear, except that keys that look like whole numbers, such as "1", "2", or "10", are moved to the front in ascending numeric order. That behavior comes from how JavaScript objects order their properties. If key order carries meaning in your document, prefer an array of objects over numeric-looking keys.

What happens if my JSON has the same key twice?+

Strict JSON does not forbid duplicate keys, but parsers handle them by keeping the last value. The tool does the same, so the earlier entry disappears from the output and no warning is shown. If an object looks shorter than you expect after formatting, search your original text for a repeated key name.

How do I locate the line that caused the error message?+

Read the message for a position or a quoted snippet of your text. Counting characters is awkward in a long document, so look at the snippet and search for it in your input box. Remember that the parser stops at the first problem it meets; once you fix that one, a second error further down may appear, so repeat until the green Valid JSON label shows.

Found this useful? Share it

Help someone else out — or link to it from your own site.

Link to this tool

Writing about json formatter? Paste this on your site to link here.

<a href="https://everyfix.net/tools/json-formatter/">JSON Formatter</a> by <a href="https://everyfix.net">EveryFix</a>