Skip to content

JSON Formatter: The Complete Guide to Format, Validate & Debug JSON

The complete JSON formatter guide — syntax rules, real parser errors, security risks, and precision bugs. Free, client-side JSON formatter, no sign-up.

Try it now: JSON Formatter & Validator Format, validate and minify JSON in your browser. Pinpoints syntax errors by line and column, sorts keys for clean diffs, and never uploads your data.

What Is a JSON Formatter?

JSON (JavaScript Object Notation) is a data format defined by RFC 8259. A JSON formatter takes JSON text and rewrites its whitespace — indentation, line breaks, spacing around punctuation — without touching the data it represents. Whether you call it a JSON formatter, a JSON beautifier, a JSON viewer, or you just want to format JSON online because a browser tab is faster than opening an editor, it's the same job: {"id":1,"active":true} and a neatly indented version of it are the same document. Every key, value, and structural relationship is identical — only the presentation changed.

Two directions fall out of that one job:

  • Beautify (pretty-print): add indentation and line breaks so nesting is visible at a glance — what you want after pasting a minified API response out of DevTools.
  • Minify (compact): remove every byte of insignificant whitespace — what you want before checking a JSON fixture into a test suite, or when measuring the actual payload size a client downloads.

A formatter can only do either safely once it knows the input is syntactically valid JSON, which is why a competent JSON formatter online — this one included — runs your input through a real parser first rather than doing find-and-replace on whitespace.

Where JSON's Rules Actually Come From

JSON has been standardized twice, by two different bodies, kept intentionally in sync — so "valid JSON" is a well-defined, testable property, not a matter of opinion or one browser's quirks.

  • RFC 8259"The JavaScript Object Notation (JSON) Data Interchange Format," published by the IETF in December 2017. It obsoletes RFC 7159, which itself succeeded the original RFC 4627 authored by Douglas Crockford, who popularized JSON in the early 2000s as a way to pass structured data between a browser and a server without the ceremony of XML. RFC 8259 additionally carries the designation STD 90 — IETF Internet Standard status, the highest maturity level a specification can reach in that process.
  • ECMA-404"The JSON Data Interchange Syntax,"published by Ecma International (the same body behind ECMA-262, the JavaScript language spec). It describes only the grammar; RFC 8259 goes further and also covers interoperability pitfalls — like the number-precision issue covered later in this guide — and security considerations a pure syntax spec doesn't need to address.

A correctly built formatter validates against that formal grammar — not against "whatever eval()would accept," which is the trap a lot of older, informal JSON tools fell into.

JSON Syntax Rules

JSON has exactly six value types, and every valid document is one value built recursively out of those six:

the json value tree
JSON Value
├─ Object   unordered key/value pairs — keys must be strings
├─ Array    ordered list of values
├─ String   double-quoted Unicode text
├─ Number   integer or float, no leading zeros
├─ Boolean  true or false
└─ Null     the literal null

An object's values and an array's elements can themselves be
any JSON value — including more objects and arrays.

A few rules trip people up constantly because they're borrowed from JavaScript object literals but aren't legal in strict JSON:

invalid json — and why each line breaks
{
  id: 7421,                       // keys MUST be double-quoted strings
  'name': 'Ava Chen',             // single quotes are never valid in JSON
  "active": True,                 // booleans are lowercase: true / false
  "roles": ["admin", "editor",],  // trailing comma before ] is invalid
  "manager": undefined,           // undefined does not exist in JSON — use null
  "score": 01.50,                 // leading zeros before a decimal are invalid
}
  • Object keys are always strings — {1: "a"} is invalid; it must be {"1": "a"}.
  • Numbers cannot have leading zeros, a leading +, or be NaN, Infinity, or hexadecimal — only base-10 decimal notation, with an optional -, a fraction, and an exponent.
  • Control characters inside a string must be escaped: \n, \t, \", \\, \uXXXX.
  • Trailing commas are never allowed in strict JSON, even though they're legal in JavaScript object/array literals and in JSON5.
  • Comments do not exist in JSON, in any position — this is what makes a tsconfig.json technically JSONC, not JSON.

JSON Formatter vs. Beautifier vs. Validator: What's Actually Different

These terms get used almost interchangeably in search results, which is why so many competing pages hedge instead of answering the question directly. Here's the distinction, stated plainly:

TermWhat it doesWhat it doesn't do
FormatterRe-indents or compacts JSON. Implies parsing first, so it also catches syntax errors as a side effect.Doesn't check structure against any external rule — a syntactically valid document with the wrong fields still "formats" fine.
BeautifierA synonym for the pretty-print direction of the same operation.Same limits as a formatter — never implies minify or validation on its own.
ValidatorConfirms a document is correct — syntactically (does it parse) or structurally (does it match a schema).A pure validator often reports pass/fail with no reformatted output.

If you searched "json validator"expecting a syntax check — is this parseable at all — rather than schema validation, this page's formatter is what you want: parsing is built in, and failures are located by line and column. GenKitLab keeps the heavier question separate:

Real-World Use Cases

JSON tooling means something slightly different depending on where you sit in the stack.

  • Backend & API developers — beautify a raw response body from curl or a REST client to actually reason about nested objects and array lengths, then run a JSON Diff against a saved "golden" response instead of eyeballing minified text for a missing field.
  • Frontend developers— turn an API's raw JSON shape into something the type system understands: JSON to TypeScript gets a starting interface in seconds; for runtime validation too, JSON to Zod generates a schema you can call .parse() on.
  • QA & test engineers— minify large fixtures to keep repo diffs small; beautify with sorted keys the moment a test fails and you need to visually diff "expected" against "actual" without key-order noise. JSONPath Tester extracts a single deeply nested field for an assertion without a chain of bracket lookups.
  • DevOps & platform engineers — hand-edited config (Terraform outputs, Kubernetes manifests, CI payloads) is prone to trailing commas and stray quotes; machine-generated JSON needs minifying before it fits an environment variable. CSV to JSON turns a spreadsheet export of hosts or feature flags into something automation can consume.
  • Technical writers — beautify a raw API response with consistent 2-space indentation before it goes into documentation, and validate first so readers never copy-paste an example that fails.

How to Format JSON in Code

An online tool is right for a one-off paste. It's the wrong tool the moment formatting needs to run in a script, a git hook, or a CI step — which is usually what someone searching json formatter python actually needs: the code, not another browser tab.

Python: json.dumps

python
import json

with open("data.json") as f:
    data = json.load(f)

# indent=2 pretty-prints; sort_keys=True gives a stable, diffable output
print(json.dumps(data, indent=2, sort_keys=True))

json.load raises json.decoder.JSONDecodeError on invalid input, with .lineno, .colno, and .posattached — enough to build the same “exactly where it broke” message a good formatter shows you. For a one-liner with no script file, Python ships a CLI for this too:

shell
python -m json.tool data.json
python -m json.tool --sort-keys data.json   # add key sorting
python -m json.tool --compact data.json     # minify instead of pretty-print

JavaScript: JSON.stringify

javascript
const data = JSON.parse(rawJson);

// second arg is a "replacer" (null = include everything); third is the indent
console.log(JSON.stringify(data, null, 2));

JSON.parse throws a SyntaxErroron invalid input, but the message isn't standardized across engines — V8 (Chrome, Node), SpiderMonkey (Firefox), and JavaScriptCore (Safari) each phrase it differently, and a trailing comma comes back from V8 with no position at all. That inconsistency is exactly why a formatter with its own error locator is worth using over raw engine output. The replacer argument also drops or renames keys on the way out:

JSON.stringify(data, (key, value) => (key === "password" ? undefined : value), 2);

Sorting keys for a stable diff

Object key order carries no semantic meaning in JSON, so sorting it recursively before diffing two payloads eliminates false-positive changes that are really just key-order noise. Array order is left alone in every case below — array position is data, not formatting:

javascript — recursive key sort
function sortKeys(value) {
  if (Array.isArray(value)) return value.map(sortKeys);
  if (value !== null && typeof value === "object") {
    return Object.keys(value)
      .sort()
      .reduce((acc, k) => ({ ...acc, [k]: sortKeys(value[k]) }), {});
  }
  return value;
}
console.log(JSON.stringify(sortKeys(data), null, 2));
python — json.dumps has native key sorting
print(json.dumps(data, indent=2, sort_keys=True))
shell — jq -S sorts object keys recursively, arrays untouched
jq -S '.' response.json

Command line: jq

shell
cat data.json | jq .          # pretty-print with syntax highlighting
cat data.json | jq -S .       # pretty-print with keys sorted
cat data.json | jq -c .       # compact (minify)

jq .alone validates and pretty-prints in one shot — it exits non-zero and prints a parse error to stderr if the input isn't valid JSON.

A Worked Edge Case: Duplicate Keys and a 64-Bit ID

Two separate bugs live in this one example, easy to conflate but worth telling apart:

input
{
  "eventId": 714341252076979033,
  "eventId": "duplicate-key-example",
  "payload": { "ok": true }
}
output after JSON.parse, in a browser or Node.js
{
  "eventId": "duplicate-key-example",
  "payload": { "ok": true }
}

First, this document has a duplicate key. That's not a syntax error — RFC 8259 permits it syntactically — but the behavior is implementation-defined, and every mainstream parser, including JSON.parse, silently keeps only the last occurrence and discards the earlier one. The numeric value is gone, with no warning.

Second, and separately: if that first eventId had been the only one, JSON.parse would have converted 714341252076979033 into a JavaScript number — and because JavaScript numbers are IEEE-754 doubles with a safe-integer ceiling of Number.MAX_SAFE_INTEGER (9007199254740991, i.e. 2^53 − 1), this 19-digit ID exceeds that ceiling and would have silently rounded to 714341252076979072, with no error thrown. The next section covers this precision bug in full.

javascript — the precision loss, demonstrated
const parsed = JSON.parse('{"eventId": 714341252076979033}');
console.log(parsed.eventId); // 714341252076979072 — wrong, no error
python — no bug here, for a different reason
# Python's int type is arbitrary-precision, so json.loads keeps the exact
# integer. (Python floats are still IEEE-754 doubles — this immunity is
# specific to integers, not to JSON numbers generally.)
import json
parsed = json.loads('{"eventId": 714341252076979033}')
print(parsed["eventId"])  # 714341252076979033 — exact

Common JSON Syntax Errors (and How to Fix Them)

JSON's grammar is stricter than the JavaScript object literal syntax it resembles. Almost every "why won't this parse" question traces back to one of a few causes:

ErrorCauseFix
Trailing comma before } or ]{"a": 1,} — valid in a JS object literal, invalid in JSON. The most common hand-edit mistake, and the one V8 reports with no position at all.Delete the comma after the last property or array element.
Single-quoted strings or unquoted keys{name: 'Ada'} — JSON requires double-quoted strings, and keys must be quoted too.Replace every ' with ", and quote every key.
Comments (// or /* */)Valid in JSONC (tsconfig.json, VS Code settings) — not valid in strict JSON.Strip comments before feeding the file to a strict JSON parser.
NaN, Infinity, undefined as valuesValid JavaScript, never valid JSON.Use null, or an actual number/string the consumer expects.
Truncated or concatenated documents"Unexpected end of input" means the document was cut off. "Unexpected non-whitespace character after JSON" usually means two documents got pasted as one.Re-copy the full payload, or wrap multiple JSON Lines records in [ ... ] separated by commas.
Duplicate keys{"status":"pending","status":"done"} parses without error — JSON.parse silently keeps only the last occurrence.Grep the raw text for the key name before formatting if a duplicate is the actual bug.

The exact wording, engine by engine

The same underlying mistake reads completely differently depending on where it's thrown:

EngineVerbatim messageWhat it means
V8 (Chrome, Node.js)SyntaxError: Unexpected token ',' in JSON at position 42Character offset into the string — not line/column.
V8, trailing comma before }Unexpected token } in JSONNo position at all — the hardest V8 case. A formatter's own re-scanner has to localize it.
Firefox (SpiderMonkey)SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data"Column 1" on a large document usually means the whole string isn't JSON — often an HTML error page.
Safari (JavaScriptCore)SyntaxError: JSON Parse error: Unrecognized token '<'Almost always means you fed it HTML — the < is an opening <html> or <!DOCTYPE> tag.
Python (json module)json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)Reached character zero and found nothing recognizable — empty input or non-JSON text.

One more failure mode is worth knowing, because it isn't a syntax error and no formatter will flag it: large integers. JSON numbers have no fixed precision limit, but JavaScript's number type does — anything past 2^53 (about 9 quadrillion) can come back rounded after a JSON.parseJSON.stringify round trip. A 64-bit database ID or a Snowflake ID is exactly the kind of value this bites — the next-but-one section covers it in full.

JSON Security: What Actually Goes Wrong

Two distinct, real risks — and one popular misconception worth correcting.

Prototype pollution — correctly explained

Here's the misconception: many people believe that parsing {"__proto__": {"isAdmin": true}}directly modifies an object's prototype chain. It does not. Try it:

javascript
const parsed = JSON.parse('{"__proto__": {"isAdmin": true}}');
console.log(Object.getPrototypeOf(parsed) === Object.prototype); // true — unchanged
console.log(parsed.hasOwnProperty("__proto__")); // true — it's a normal own property!
console.log(parsed.__proto__); // { isAdmin: true } — just a regular value under a weird key

JSON.parse treats __proto__ as nothing more than a string key. The result is a perfectly ordinary object that happens to have an own property literally named __proto__— it does not touch the object's actual prototype.

The real vulnerability shows up one step later, and only if that parsed object is then fed into an unsafe deep-merge or deep-clone utility — one that recursively copies properties from a source object onto a target object, including a key named __proto__, without guarding against it. In that scenario, the merge function can end up doing the equivalent of target.__proto__.isAdmin = true, which does reach into Object.prototype — polluting every plain object in the running process, including ones that have nothing to do with the original payload. The fix lives in the merge/clone utility, not in JSON.parse itself: explicitly reject __proto__, constructor, and prototype as keys during recursive assignment, or build the target object with Object.create(null) (no prototype to pollute) or a Map when merging untrusted data.

Where your JSON actually goes

Ask this before pasting a production API response, an auth token, or a customer record into any web tool — it's the right instinct, and most tool pages don't answer it directly. In November 2025, watchTowr Labs reported that two long-standing, widely used online JSON tools — jsonformatter.org and codebeautify.org — had been storing user-submitted content through a "Recent Links" save/share feature with predictable, enumerable URLs. That exposed more than 80,000 snippets — roughly five years of JSONFormatter history and a year of CodeBeautify's — to anyone who crawled the URL pattern, including live AWS access keys, GitHub personal access tokens, database passwords, and other credentials people had pasted in for formatting. watchTowr also planted canary AWS credentials on both sites and reported active scrapers attempting to use them within 48 hours. Per that reporting, both platforms appear to have quietly disabled the save/share feature — likely in response to watchTowr's outreach — but watchTowr says many of the organizations it tried to notify about their own exposed data never responded.

This is the practical argument for a client-side tool, not a theoretical one. If a formatter processes your input on a server — even one with good intentions — that input has, at minimum, crossed the network and touched infrastructure you don't control, and history shows "we don't store it" is not always true in practice. For GenKitLab's JSON formatter, specifically: everything runs client-side. Parsing, formatting, minifying, key sorting, and error location all happen in JavaScript in your browser tab — there is no network request that carries your pasted content anywhere. Verify it yourself in under a minute: open DevTools, switch to the Network tab, paste a payload, format it — no request fires. That verifiability matters more than the claim itself, because there's no server-side code path that could leak the payload even by accident. Be more careful with tools that bundle formatting into a larger "editor" product with sync, sharing, or account features — the more a tool does beyond pure local formatting, the more likely some part of it touches a server.

Number Precision: The Silent Data-Loss Bug

This is the JSON bug most likely to cost you a debugging session, precisely because it never throws an error.

JSON.parse converts every bare JSON number into a native JavaScript number — always an IEEE-754 double-precision float, even when the source value was logically an integer. Doubles can represent integers exactly only up to Number.MAX_SAFE_INTEGER (9007199254740991, i.e. 2^53 − 1). Beyond that ceiling, some integers simply have no exact double representation, and the nearest one gets silently substituted — no error, no warning. This is exactly the shape of bug that hits 64-bit database primary keys, Snowflake-style distributed IDs, and social-platform status IDs — anything generated as a large integer on a backend that doesn't think in JavaScript-number terms, then passed through a JS-based API layer or frontend.

Two real fixes, both used in production systems:

  • A reviver function on JSON.parsecan intercept and convert specific fields before they're used — but it works reliably only when combined with a parser that preserves the original digit string, since the native reviver alone receives the already-rounded double for a plain numeric literal. It cannot recover precision that's already lost by the time it runs.
  • Emit the value as a quoted string at the source— the reliable fix. A quoted numeral is never numerically parsed, so it's never rounded:
json — quoting at the source
{ "id": "714341252076979033", "name": "example" }
javascript
const parsed = JSON.parse('{"id": "714341252076979033", "name": "example"}');
console.log(parsed.id); // "714341252076979033" — exact, because it's a string
console.log(BigInt(parsed.id)); // 714341252076979033n — convert only when you need to do math

If you control the API or database layer emitting these IDs, quoting them at the source is the fix that actually holds up across every consumer — browsers, Node, and any other JSON parser downstream — because it removes the ambiguity at the format level instead of trying to patch around it after the fact.

JSON Schema, Briefly

JSON itself has no built-in way to say "this field is required" or "this string must be an email address." JSON Schema is the widely adopted vocabulary for describing exactly that — the shape, types, and constraints a JSON document must satisfy — so tooling can validate data automatically instead of relying on someone reading documentation carefully.

The current stable version is Draft 2020-12, published at json-schema.org. A few notable changes from the prior 2019-09 draft, if you're maintaining schemas written against an older version:

  • Tuple-style array validation moved from items/additionalItems to prefixItems (fixed-position entries) combined with items (anything after).
  • $recursiveRef and $recursiveAnchor were replaced by $dynamicRef and $dynamicAnchor, a more flexible mechanism for self-referencing schemas.
  • unevaluatedProperties and unevaluatedItems moved into their own required vocabulary, rather than being bundled implicitly with the core spec.

A minimal example — a schema describing the sorted user object from the key-sorting example above:

schema.json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "requestId": { "type": "string" },
    "user": {
      "type": "object",
      "properties": {
        "id": { "type": "integer" },
        "active": { "type": "boolean" },
        "roles": { "type": "array", "items": { "type": "string" } }
      },
      "required": ["id", "active"]
    }
  },
  "required": ["requestId", "user"]
}

Formatting and validating raw JSON syntax is a separate, earlier step from schema validation — you need syntactically valid JSON before a schema validator can even begin checking its shape. Once your syntax is clean, GenKitLab's JSON Schema Validator checks a document against a schema like the one above and reports every failure by JSON Pointer, so you know exactly which field violated which rule.

JSON vs YAML vs XML

None of these formats is objectively "best" — they trade off differently, and picking the wrong one for the job (not the format itself) is usually the actual problem.

JSONYAMLXML
Syntax weightLight — brackets, quotes, colonsVery light — whitespace-significantHeavy — open/close tags for everything
CommentsNot supportedSupported (#)Supported (<!-- -->)
Human editingFine for small/medium docsExcellent — often the most pleasant to hand-editVerbose; tedious for anything nontrivial
Whitespace significanceInsignificant — purely cosmeticSignificant — indentation is the structureInsignificant
Known gotchasMinimal, given a strict parserUnquoted no/yes/on/off parsed as booleans in some parsersAttributes vs. elements is a recurring design decision
Typical use casesAPIs, data interchange, NoSQL documentsCI pipelines, Kubernetes manifests, Docker ComposeSOAP/legacy enterprise APIs, strict XSD schemas

GenKitLab JSON Formatter vs. the Alternatives

GenKitLabjsonformatter.org / codebeautify.orgVS Code extension
Where processing happensEntirely in your browserServer-side, historically, per public reportingLocally, inside your editor
Data retentionNothing uploaded, logged, or storedNov. 2025: watchTowr reported 80,000+ exposed snippets, including live credentialsN/A — stays on your disk unless you paste it elsewhere
Error location precisionExact line/column/caret, incl. the V8 no-position caseVaries by siteGood — integrated with editor diagnostics
Key sorting for diffsBuilt in, recursive, array order preservedNot a standard featureRequires an extension
Sign-up requiredNoNoNo (bundled with or added to an existing editor)
Best fitA one-off paste of real, possibly sensitive dataQuick formatting where content isn't sensitiveFiles already open in your editor

The honest read: a VS Code extension is genuinely the better tool when you're already editing a file in your project — offline, integrated, fast. It's not built for "I have a blob of JSON in my clipboard right now, from a terminal or a Slack message, and I need it readable in the next five seconds" — that specific gap is what a browser-based formatter fills, which is exactly why the storage practices of that category of tool matter so much: you're often pasting real production data into it.

Formatting JSON in Your Editor

For JSON that already lives in a file, reaching for a browser tab is usually one step too many — this is the json formatter vscode question. VS Code formats JSON natively:

  • Format Document: Shift+Alt+F (Windows/Linux) or Shift+Option+F (macOS) — no extension required.
  • Format on save: set "editor.formatOnSave": true in settings.json, scoped to JSON only if you don't want it everywhere.
settings.json
{
  "[json]": {
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "vscode.json-language-features"
  }
}

VS Code's JSON language service can also attach a schema to a file (via $schema, or the json.schemas setting) for inline validation and autocomplete while typing — the editor equivalent of what a schema validator tool does after the fact.

Explore More JSON Tools

This formatter is one piece of a JSON toolchain — GenKitLab runs a full JSON tools category, all client-side, all free:

  • JSON Schema Validator — validate structure against a JSON Schema, with every failure located by JSON Pointer.
  • JSON Diff & Compare — compare two documents structurally, so reformatting and key order are ignored.
  • JSON Minifier — the dedicated minify-only tool, with an exact byte-savings readout.
  • JSON to TypeScript — generate TypeScript interfaces from a JSON sample.
  • JSONPath Tester — run a JSONPath expression against a document and see every matching node.
  • JSON ↔ CSV Converter — convert either direction with nested-object flattening.

And for JSON embedded in other formats: JWT Decoder decodes the JSON header and payload inside a token, Base64 Encoder & Decoder unwraps base64-encoded JSON blobs from cookies and query strings, and Regex Tester is useful for scrubbing or extracting values out of raw JSON text before it's valid enough to parse.

References

  1. Bray, T., Ed. The JavaScript Object Notation (JSON) Data Interchange Format. RFC 8259 / STD 90. Internet Engineering Task Force, December 2017.
  2. Ecma International. ECMA-404: The JSON Data Interchange Syntax, 2nd edition.
  3. Mozilla Developer Network. "JSON.parse()." MDN Web Docs.
  4. Mozilla Developer Network. "BigInt." MDN Web Docs.
  5. JSON Schema Organization. "Specification: Draft 2020-12." json-schema.org.
  6. watchTowr Labs (research by Jake Knott). Findings on 80,000+ exposed user-submitted files — including live credentials — on jsonformatter.org and codebeautify.org, reported November 25, 2025, via The Hacker News: "Years of JSONFormatter and CodeBeautify Leaks Expose Thousands of Passwords and API Keys."

Frequently asked questions

What is a JSON formatter?

A JSON formatter rewrites JSON text's whitespace — indentation and line breaks — without changing the data it represents. "Beautify" adds structure for readability; "minify" strips it for size. Both require parsing the input first, so a formatter necessarily also validates syntax as a side effect.

What's the difference between a JSON formatter, beautifier, and validator?

"Formatter" and "beautifier" are effectively synonyms for the pretty-print direction of the same operation. "Validator" is a distinct question with two levels: syntax validation (does this parse as JSON at all) and schema validation (does this valid JSON match a specific structure), which needs a schema document to check against.

How do I format JSON in Python or JavaScript without an online tool?

In Python: json.dumps(data, indent=2, sort_keys=True), or python -m json.tool file.json from the command line. In JavaScript: JSON.stringify(data, null, 2), where the third argument is the indent width. Both parse the input first, so both raise on invalid JSON before producing malformed output.

Why is my JSON invalid ("unexpected token" errors)?

Almost always one of: a trailing comma before } or ], single-quoted strings or unquoted keys, a // or /* */ comment (valid JSONC, invalid strict JSON), or a JavaScript-only value like NaN or undefined.

Why does Chrome sometimes give me a JSON error with no position number?

This happens specifically with a trailing comma right before a closing brace — V8 reports "Unexpected token } in JSON" with no character position at all, arguably the least helpful common JSON error message across major engines. A dedicated formatter re-scans the text independently to give you the real line and column in that case.

Does JSON support comments?

No, never, in any position. This is one of the most common sources of "valid-looking" JSON that actually fails to parse, especially when copying from a tsconfig.json or similar comment-bearing config dialect (JSON5/JSONC), which are different, looser formats that only resemble JSON.

What happens if my JSON has duplicate keys?

It's not a syntax error under RFC 8259, but behavior is implementation-defined, and in practice virtually every parser — including native JSON.parse — silently keeps only the last occurrence of a duplicate key and discards the earlier ones, with no warning.

Why did my large ID number change after I parsed my JSON?

Because JavaScript numbers are IEEE-754 doubles, which can only exactly represent integers up to Number.MAX_SAFE_INTEGER (9007199254740991). A larger integer, like a 64-bit database ID, silently rounds to the nearest representable double during JSON.parse — no error is thrown. The reliable fix is to have the source system emit that field as a quoted string instead of a bare number.

Is it safe to paste sensitive JSON — like an API key or password — into an online formatter?

It depends entirely on where processing happens. Server-side tools transmit your paste to their infrastructure; in November 2025, security researchers at watchTowr reported that jsonformatter.org and codebeautify.org had exposed over 80,000 previously submitted snippets — including live credentials — through an unprotected feature. A tool that runs fully client-side, like GenKitLab's JSON formatter, never transmits your input anywhere, which removes that specific risk.

Can JSON.parse() be tricked into prototype pollution by itself?

No — this is a common misconception. JSON.parse('{"__proto__": {"isAdmin": true}}') produces a plain object with an ordinary own property named "__proto__"; it does not modify the object's actual prototype. The real risk only appears if that parsed object is later passed into an unsafe recursive merge/clone function that copies the __proto__ key onto a target object without guarding against it.

Can a JSON formatter fix broken JSON automatically, or only reformat valid JSON?

Only reformat what's already valid. A trustworthy formatter parses first and refuses to guess at a fix for a syntax error — silently "repairing" broken JSON risks producing a document that parses but no longer matches the data that was actually sent.

What's the difference between minifying and formatting JSON?

Formatting (beautifying) adds indentation and line breaks for human readability. Minifying strips every character of insignificant whitespace to produce the smallest possible payload — useful for reducing transfer size or fitting data into size-constrained fields like environment variables.

Why does key-sorting only reorder object keys and not array items?

Because object key order carries essentially no semantic meaning in JSON (an object is an unordered set of key/value pairs per the spec), while array order is data — the position of an element in an array is often meaningful. Sorting object keys makes diffs stable; reordering an array would silently change what the data means.

How do I format JSON directly in VS Code?

Open the file and press Shift+Alt+F (Windows/Linux) or Shift+Option+F (macOS) — JSON formatting is built in, no extension required. To format automatically, set "editor.formatOnSave": true, optionally scoped to "[json]" in settings.json.

Does GenKitLab's JSON formatter support JSON5 or JSONC with comments?

No, by design — it validates strict JSON only, per RFC 8259. That strictness is exactly what allows it to report exact, reliable error line/column locations rather than guessing at intent. If you're working with a comment-bearing config format, strip the comments before pasting.

What is JSON Schema, and do I need it just to format JSON?

JSON Schema (currently at Draft 2020-12) is a separate vocabulary for describing constraints on a JSON document's shape — required fields, types, formats. You don't need it to format or validate basic JSON syntax; you need it only when you want to verify that already-valid JSON also matches a specific expected structure.

Last updated