Skip to main content
L
Loopaloo
Buy Us a Coffee
All ToolsImage ProcessingAudio ProcessingVideo ProcessingDocument & TextPDF ToolsCSV & Data AnalysisConverters & EncodersWeb ToolsMath & ScienceGames
Guides & BlogAboutContact
Buy Us a Coffee
L
Loopaloo

Free online tools for developers, designers, and content creators. Your files are processed in your browser and are never uploaded - no accounts required. A few network utilities (like What's My IP and Currency Converter) call public APIs to do their job and say so on their pages.

support@loopaloo.com

Tool Categories

  • Image Tools
  • Audio Tools
  • Video Tools
  • Document & Text
  • PDF Tools
  • CSV & Data
  • Converters
  • Web Tools
  • Math & Science
  • Games

Company

  • About Us
  • Contact
  • Blog
  • FAQ

Legal

  • Privacy Policy
  • Terms of Service
  • Disclaimer

Support

Buy Us a Coffee

© 2026 Loopaloo. All rights reserved. Built with privacy in mind.

Privacy|Terms|Disclaimer
  1. Home
  2. Document & Text
  3. JSON Formatter & Validator
Add to favorites

JSON Formatter & Validator

Format, validate and minify JSON, JSON with comments and JSON5, without changing a single value: every number is written back as the document spelled it. Errors carry a line, a column and the offending line. JSONPath queries, tree view, schema checks and diff

Text processed locallyMore document & textJump to full guide

Related reading

  • XML and XPath: Understanding Structured Data and Powerful Queries12 min read
  • JSON Best Practices: Structure, Validation, and Common Mistakes9 min read

Initializing in your browser…

You might also like

XML Formatter & Tools

Format and validate XML without changing the document: CDATA, xml:space="preserve" and mixed content all survive, with errors carrying a line, a caret and a next step, plus XPath queries, a tree view and JSON conversion that names what JSON cannot carry

YAML Formatter & Converter

Format YAML without rewriting it: comments, anchors, quoting, block scalars, multi-document streams and the exact spelling of every number all survive, with YAML 1.1 and 1.2 both offered because the same file means different things under each

JSON Schema Generator

Generate a JSON Schema from a document and see whether it actually validates that document, with every number written back exactly as the file spelled it and formats checked against the calendar and the clock rather than by pattern

JSON Formatter & Validator: a worked example

An API returned a single minified line of JSON holding an order identifier and a price, and you need to read it before filing a bug.

Minified

{"orderId":12345678901234567890,"price":19.90,"active":true}
What JSON Formatter & Validator produces

Formatted, with nothing changed

{
  "orderId": 12345678901234567890,
  "price": 19.90,
  "active": true
}

line 1:12  12345678901234567890 is written back exactly as it is.
           Read as a double it would be 12345678901234567000,
           which is a different document.

Most formatters run JSON.parse then JSON.stringify, which turns every number into a 64-bit float: that identifier comes back 12345678901234567000 and the price comes back 19.9. RFC 8259 section 6 sets no limit on the digits in a JSON number, so neither loss is required by the spec. This tool reads the document into a tree carrying the source text of every value and writes that text back, then tells you which numbers a float-based reader would round. Errors carry a line, a column and the offending line with a caret under it, and comments in JSONC and JSON5 are found with a lexer, so a URL inside a string survives.

About the JSON Formatter & Validator

JSON is strict about syntax in ways that surprise people. The spec (RFC 8259) requires double-quoted keys (single quotes are invalid), forbids trailing commas, forbids comments entirely, and requires all strings to be UTF-8. JavaScript object literals violate most of these rules and that is the most common source of confusion: code like `{foo: 1, "bar": 2,}` is valid JavaScript and invalid JSON. This formatter validates against the JSON spec, pretty-prints the result with configurable indentation, and reports the exact line and column of any error, with the offending line and a caret under the character, so you can find the problem without counting. The rule it holds to is that FORMATTING A DOCUMENT CHANGES ONLY ITS WHITESPACE. That sounds obvious and the usual implementation breaks it immediately: `JSON.stringify(JSON.parse(text))` turns every number into a 64-bit float and writes back whatever the float prints as, so the order identifier 12345678901234567890 comes out 12345678901234567000, the price 19.90 comes out 19.9, negative zero comes out 0, and 1e400 comes out null. RFC 8259 section 6 sets no limit on the digits in a JSON number, so none of that is required by the spec; it is an artefact of going through a float. This tool never turns the token into a number at all. It reads the document into a tree that carries the source text of every value and writes that text back, and it tells you which numbers a program using doubles would round, so you know before it bites you. Everything happens in your browser, which matters because JSON frequently contains credentials, API keys, or customer data you would rather not paste into a random online service. The collapsible tree view is built from the same tree, so it also shows the digits the file held rather than a rounded copy.

How it works

Indentation choice has subtle practical consequences. 2-space indent is the default in most JavaScript and web tooling, it keeps nested structures readable without consuming horizontal space, which matters when JSON gets embedded in code or documentation with margin constraints. 4-space indent matches Python's convention and is easier to scan at deep nesting levels because each level is visually distinct at a glance. Tab indentation is rare in JSON but occasionally required by legacy tooling. All four choices are here (2, 3, 4 spaces and a real tab character), alongside a minification mode that strips all whitespace for size-sensitive transport.

Comments and trailing commas cannot be removed with a search and replace, and that is worth stating because most tools try. A regular expression cannot tell a `//` that starts a comment from one inside a string, so a document holding `{"url": "https://example.com/a"}` gets cut at the first slash and stops parsing, and one holding `{"a": "/* keep this */"}` has its value emptied and still parses, which is worse. This tool reads with a lexer instead. Choose the dialect at the top: JSON is RFC 8259 exactly; JSON with comments adds // and block comments and a trailing comma in either container, which is what tsconfig.json and VS Code settings use; JSON5 adds unquoted names, single quotes, hexadecimal and leading-point numbers, a leading plus, Infinity and NaN, and line continuations inside strings. Writing a JSON5 document back out as JSON has to change some tokens, and every one of those changes is listed with its path and the reason, rather than happening silently.

Two members of one object can share a name. RFC 8259 section 4 says names SHOULD be unique and stops short of forbidding a repeat, and every mainstream parser quietly keeps the last one, so `{"price": 19.90, "price": 24.90}` becomes a single price and nothing tells you which. Here the repeat is reported with its line, both members survive by default, and if you do want one of them there is a setting saying which and a list of what it removed. The same care goes to member order: a JavaScript object silently reorders integer-like names ahead of everything else in ascending order, so `{"2":…,"10":…,"1":…}` comes back as 1, 2, 10 from any tool built on one. This tool keeps the order the file had unless you ask for a sort, and when you do it says which collation it used, because sorting by code point and sorting by your language are different orders.

It is worth knowing what JSON genuinely does not support. There is no Date type (ISO 8601 strings are the convention), no comments (teams invent hacks like `"_comment"` fields, or use JSONC), no multiline strings (you need literal \n escapes), and no undefined (null is the only nothing-value). What JSON does NOT lack is large numbers: section 6 sets no digit limit and only recommends the binary64 range for interoperability. Whether 12345678901234567890 survives depends entirely on what reads it, which is why this tool leaves it alone and warns you instead.

How to use

  1. 1Paste raw or minified JSON into the input editor, or import a file
  2. 2Choose the dialect: JSON, JSON with comments, or JSON5
  3. 3Press Format, or Minify to strip every space
  4. 4Read the report above the panes: what the document holds, anything worth knowing about it, and any token that had to be written differently
  5. 5Collapse or expand nested sections in the Tree tab to focus on specific parts
  6. 6Copy or download the result

Key features

  • Formatting that changes only whitespace: every number is written back as the source spelled it, so a 20 digit identifier, a trailing zero and a negative zero all survive
  • Numbers a 64-bit float cannot hold exactly are reported with what a program using one would read instead
  • Errors carry a line, a column, the offending line with a caret under it, and a suggested fix where there is an obvious one
  • Three dialects read with a real lexer: JSON (RFC 8259), JSON with comments, and JSON5 1.0.0
  • Converting JSON5 to JSON lists every token it had to change, with the reason
  • Repeated member names are reported rather than silently collapsed, with a setting for which one to keep
  • Member order is the file's order unless you sort, and the sort states its collation
  • Indentation of 2, 3 or 4 spaces or a real tab character, plus a minify mode
  • Collapsible tree view built from the same tree, so it shows the source digits too
  • Syntax highlighting driven by the lexer, so a string containing a colon is not coloured as a key
  • JSONPath queries, a JSON Schema check, and a value-by-value diff against a second document
  • Copy and download; everything runs in your browser

When to reach for this

  • Debugging API responses

    Format minified API responses into readable JSON to inspect data structures, spot missing fields, or verify correct values.

  • Cleaning up config files

    Reformat messy configuration files with consistent indentation before committing to version control.

  • Validating JSON data

    Catch syntax errors, missing brackets, extra commas, unquoted keys, before they cause runtime failures in your application.

  • Exploring unfamiliar data structures

    Collapse and expand nested objects to understand the shape of large JSON documents from third-party APIs or databases.

  • Preparing JSON for documentation

    Format example payloads cleanly for API docs, README files, or technical specifications.

Tips & best practices

  • Use the minify button to strip whitespace before sending JSON over the network, it can significantly reduce payload size.
  • If a parse error is somewhere you cannot see, read the caret line under the excerpt: it points at the exact character, and the message names the line a container was opened on when the problem is an unclosed one.
  • Before you send an identifier to an API, check whether the report flagged it as beyond a double. If it did, the receiving end will probably round it unless it parses numbers as strings.
  • Sorting by code point puts every capital before every lower case, because that is the order the characters are in. Sorting by your language does what a dictionary does. Neither is wrong; pick the one the thing reading the file expects.

Frequently asked questions

Can this tool fix invalid JSON?

It identifies and reports syntax errors with their location, and where there is one obvious fix it names it: a Python True becomes true, a single quote is JSON5, a comma before a closing brace can be removed or the dialect switched. It does not apply the fix for you, because a missing comma could mean "add a comma" or "remove the key after it" and the tool cannot know your intent.

Why did another formatter change my numbers?

Because it went through JSON.parse and JSON.stringify. That turns every number into a 64-bit float and writes back what the float prints as, so 12345678901234567890 becomes 12345678901234567000, 19.90 becomes 19.9, -0 becomes 0 and 1e400 becomes null. RFC 8259 section 6 places no limit on the digits in a JSON number; the loss comes from the float, not from the spec. This tool writes every number back as the document spelled it and tells you which ones a float-based reader would round.

Is there a size limit?

A 144 KB document of 5,000 objects formats in about two and a half seconds through the page, and 808 KB of 20,000 objects takes about 50 milliseconds in the parser itself. Everything runs in your browser, so a very large file is limited by the tab rather than by an upload.

Does it support JSON5 or JSONC (JSON with comments)?

Yes, as an explicit choice rather than a guess. Pick the dialect at the top of the tool. JSON with comments adds // and block comments and a trailing comma in either container, which is what tsconfig.json uses. JSON5 adds unquoted names, single quotes, hexadecimal and leading-point numbers, a leading plus, Infinity and NaN, and line continuations. Both are read with a lexer, so two slashes inside a string stay inside the string. Writing either back out as JSON lists every token that had to change.

What happens to two keys with the same name?

They are reported with their line, and by default both survive. RFC 8259 section 4 says names SHOULD be unique and does not forbid a repeat, and every mainstream parser keeps the last and drops the rest with no message, which is how a duplicated field becomes a silent data loss. If you want the usual behaviour there is a setting for it, and it lists what it removed.

Is my data sent to a server?

No. All formatting and validation happens entirely in your browser. Nothing is transmitted or stored.

Related tools and how they differ

  • XML Formatter & Tools: Formats and validates XML, runs XPath, and maps XML to JSON with @attributes and #text; use it when your data has attributes and namespaces, not plain key-value objects.
  • YAML Formatter & Converter: Converts YAML to and from JSON with line-numbered errors and an auto-fix for tabs and spacing; use it for config files where YAML quirks like indentation bite.
  • SQL Formatter: Beautifies SQL queries by case and clause layout; use it for database statements, not data documents. It does cosmetic formatting only, no value validation.

Further reading

  • XML and XPath: Understanding Structured Data and Powerful Queries12 min read
  • JSON Best Practices: Structure, Validation, and Common Mistakes9 min read

Private by design

Your text is processed locally in the browser. Nothing you paste or open is transmitted or logged.