JSON Formatter
Turn messy JSON into readable, compact, sorted, or line-delimited output with duplicate-key, size, and number-precision warnings in your browser.Formatted payload
Format status
| Metric | Value | Detail | Copy |
|---|---|---|---|
| {{ row.metric }} | {{ row.value }} | {{ row.detail }} |
| Path | Pointer | Type | Detail | Preview | Copy |
|---|---|---|---|---|---|
{{ row.path }} |
{{ row.pointer }} |
{{ row.type }} | {{ row.detail }} | {{ row.preview }} | |
| No nodes match the current filter. | |||||
{{ ndjsonText }}
{{ row.text || ' ' }}
{{ diffStatusText }}
| Section | Note | Copy |
|---|---|---|
| Interoperability checks | Duplicate key findings: {{ duplicateKeys.length }} | |
| Interoperability checks | Unsafe integer findings: {{ metrics.unsafeIntegerCount }} | |
| Interoperability checks | Canonical profile readiness: {{ canonicalReadyLabel }} | |
| Recommended next action | {{ note }} |
Introduction
JSON usually travels between systems as plain text, but the same data can look very different depending on the job. A compact API payload, a multi-line review draft, a sorted comparison string, and a record-per-line feed can all carry related information while serving different handoff needs. The text form affects how humans review the data, how many bytes move over the wire, and how repeatable a comparison will be.
The format is intentionally small: strings, numbers, booleans, null, objects, and arrays. Objects hold named members, arrays keep ordered values, and most whitespace around punctuation disappears after parsing. That simplicity is useful, but it also hides a few traps. Duplicate object names can leave receivers disagreeing about which value counts. Large numeric identifiers can parse successfully while losing exact digits in common browser number handling. A comment that is harmless in a draft file can make the same text invalid for a strict API.
Good JSON review separates four questions that are often mixed together: whether the text parses, whether the structure is readable, whether the serialized bytes are suitable for the destination, and whether the receiving application accepts the fields. A clean parse answers only the first question. Schema checks, signature rules, business validation, and receiver-specific size limits still need their own review.
- JSON text
- One serialized JSON value, which may be an object, array, string, number, boolean, or null.
- Object member
- A quoted name and value inside an object. For reliable interchange, names in the same object should be unique.
- Whitespace
- Spaces, tabs, and line breaks around JSON punctuation. Whitespace changes readability and byte size, not the parsed value.
- Line stream
- A record-oriented form where each line is its own JSON value, commonly called JSON Lines or newline-delimited JSON.
| Text form | Useful when | Common mistake |
|---|---|---|
| Readable indentation | Someone needs to inspect nesting, field names, and repeated shapes by eye. | Treating tidy layout as proof that the data matches a schema or contract. |
| Compact JSON | Whitespace should be removed for transport, storage, or log-friendly handoff. | Assuming fewer bytes means the payload is semantically smaller or safer. |
| Sorted serialization | Repeatable field order helps diffs, local comparison, or hash preparation. | Calling it canonical without checking the receiver's exact signing rules. |
| JSON Lines | Records need to stream one value at a time through logs, queues, or batch jobs. | Forgetting that each nonblank line must stand alone as a valid JSON value. |
Readable formatting helps code review, incident notes, and support tickets because people can scan nesting and field names without counting braces. Compact formatting helps when the same data must travel over a network or fit into a narrow log field. Sorted text without extra whitespace can make two payloads easier to compare, but it is only a deterministic local representation unless it follows the exact canonicalization rules required by the receiving system.
Draft dialects add another boundary. JSON with comments is convenient for humans, configuration notes, and examples, but ordinary JSON receivers expect the comments to be gone before the text is sent. Likewise, a JSON Lines file is useful for record processing, but it is not the same shape as one large JSON array.
The safest handoff treats formatting as a review step, not as a guarantee. Check parse errors first, then look for duplicate names, risky numbers, record-shape surprises, byte-size changes, and destination rules before signing, storing, or automating the payload.
How to Use This Tool:
Start with the handoff you need, then use the warnings and result tabs to decide whether the formatted output is ready to copy.
- Choose
Review workspacefor readable indentation,Transport payloadfor compact JSON,Signature canonicalfor sorted no-whitespace text, orCustomwhen you want direct control over the advanced settings. - Keep
Strict JSONfor production payloads. UseJSONC commentsonly when a draft contains//or block comments that should be stripped before standard JSON is emitted; trailing commas and other non-JSON syntax still need to be fixed. - Set
Indent spacesandKey orderwhen review formatting or stable comparison order matters. OpeningAdvancedlets you choose line-stream mode, final newline behavior, HTML-character escaping, slash escaping, node ledger filtering, and theChange Deltatarget. - Paste JSON into
JSON payload, drop a JSON or text file onto the editor, useBrowse JSONto load a local file, or useSampleto restore the built-in example. - Fix parse errors before using any result. When the parser can map the position, the error gives a line and column to help you find the broken character.
- Read the summary and warning alert before copying output. Duplicate keys, unsafe integers, precision-heavy numeric literals, large input, and slow formatting all change how much confidence to place in the result.
- Use
Editor Draft,Wire Payload,Signature Canonical,Line Stream,Node Ledger,Change Delta, the chart tabs,Formatter Audit, orJSONdepending on what needs to travel with the handoff. - When a warning remains, repair the producing system, quote exact identifier-like numbers, or confirm the receiver's schema and canonicalization rules before signing, ingesting, or automating the payload.
Interpreting Results:
The summary headline is a triage signal. JSON Validated and Structured means parsing succeeded without formatter warnings. Valid JSON with Caveats means output exists, but at least one warning needs review. Duplicate Key Review Needed is more serious because repeated names can leave different receivers disagreeing about which value counts.
Deterministic Signature Candidate means the signature profile produced sorted JSON without extra whitespace from the parsed value. Treat it as a comparison aid unless the system receiving the data explicitly accepts that exact representation.
| Signal | What it means | What to check next |
|---|---|---|
Duplicates above zero |
The input contains repeated object member names before ordinary parsing removes the ambiguity. | Fix the producer before schema validation, merge work, hashing, or signature prep. |
Numeric precision risks |
One or more numbers may not keep exact digits in common browser number handling. | Quote account IDs, order IDs, counters, and high-precision decimals when every digit matters. |
Wire size badge |
The compact payload is smaller or larger than the pasted input after formatting choices are applied. | Use Payload Size Chart when byte size affects transport, storage, or review limits. |
Canonical readiness |
The audit notes whether duplicate keys or unsafe integers block deterministic handoff confidence. | Compare the output with the receiver's required canonical JSON rules before signing. |
No Change Delta |
The selected formatted output matches the comment-stripped input at line level. | Still review schema expectations and warnings because a clean text diff is not a business-rule check. |
Technical Details:
JSON syntax is defined around a single value surrounded by optional whitespace. That value can be an object, array, string, number, boolean, or null. Older assumptions that a JSON document must start with an object or array still appear in some systems, so a scalar value such as true may be valid JSON while still being rejected by a stricter receiver.
Objects are written as name/value members. The JSON standard recommends unique member names because duplicate names make receiver behavior unpredictable. Some parsers keep the last value, some reject the text, and some expose every occurrence. Once ordinary parsing has collapsed duplicates, the earlier evidence can be lost, so duplicate-name review has to happen against the text that was parsed.
JSON numbers have a decimal text grammar, but applications usually store them in a finite numeric type. Very large integers and long decimal literals can therefore parse successfully while losing exactness. Identifier-like values are safer as strings when exact digits matter more than numeric arithmetic.
Transformation Path
| Stage | Rule | Review point |
|---|---|---|
| Parse text | The editor text must parse as one JSON value. In comment mode, line and block comments are removed first. | Comment removal is a draft convenience. The emitted results are standard JSON text. |
| Order object names | Object names can stay in parsed order or be sorted A to Z or Z to A for working outputs. | Sorting helps diffs and repeatability, but it can move fields away from the producer's original order. |
| Serialize forms | The parsed value is emitted as readable JSON, compact JSON, sorted JSON without extra whitespace, and optional line-stream text. | Each form answers a different handoff question; none performs schema validation. |
| Build diagnostics | Metrics, duplicate names, number warnings, paths, JSON Pointer locations, size comparisons, and type counts are derived from the parsed value and input text. | Use diagnostics to find hidden risk before trusting a tidy-looking output. |
Wire Size Formula
Compact payload byte change
A positive reduction means the compact output uses fewer UTF-8 bytes than the input text. Escaping and newline choices can change the exact byte count.
| Finding | Rule used | Why it matters |
|---|---|---|
| Duplicate object names | Repeated names within the same object are collected from the parsed input text. | Downstream systems may keep different values or reject the payload. |
| Unsafe integers | Parsed whole numbers outside the exact safe integer range are counted. | Large identifiers and counters can change value after parse and serialization. |
| Long number literals | Number tokens with more than 15 significant digits are flagged. | High-precision decimals may need to be represented as strings or handled by a decimal-aware system. |
| Large input | Input above 5 MB receives a performance warning. |
Very large payloads may be easier to inspect in smaller chunks. |
| Slow formatting | Formatting time at or above 120 ms receives a runtime warning. |
Charts, diffs, and tables may become less comfortable on lower-power devices. |
Canonicalization Boundary
The signature-oriented output sorts object names in ascending order and removes insignificant whitespace. That is useful for repeatable local comparison, hash preparation, and review. It is not a claim of full JSON Canonicalization Scheme compliance. RFC 8785 also defines stricter rules for number serialization, string handling, and property ordering that may matter to a verifier.
JSON Lines is also a separate convention rather than a different JSON grammar. Each line must be a valid JSON value, blank lines are not records, and a final newline is commonly recommended for easier concatenation. When an array is converted into one line per item, each item becomes its own JSON value for record-by-record processing.
Privacy and Limits:
- After the browser loads the tool, pasted text, dropped files, formatting, diagnostics, charts, copy actions, and downloads stay in the browser tab.
- The tool validates JSON syntax after the selected comment-stripping option. It does not validate an API schema, required fields, enum values, dates, signatures, or application rules.
- Comment mode removes
//and block comments, but it does not turn every JSON-like language into JSON. Trailing commas, unquoted object names, and single-quoted strings remain invalid for strict JSON output. - Duplicate-key warnings indicate ambiguity in the input text. The formatted output is still based on the parsed value after duplicate handling has already occurred.
- For very large payloads, use the size and runtime warnings as a cue to split the data before visual review, chart export, or line-by-line inspection.
Worked Examples:
Clean a commented draft
A support ticket includes a JSON-like snippet with // temporary note beside a field. Set Input dialect to JSONC comments, review the formatted result, then keep the output as standard JSON without comments before sending it to a strict receiver.
Prepare compact API text
An object with many line breaks and spaces can use Transport payload. The Wire Payload tab removes unnecessary whitespace, and the payload size chart shows how many bytes changed from the pasted input.
Check a signature candidate
A payload with "b":2 before "a":1 can use Signature canonical to produce sorted text without extra whitespace. If duplicate keys or unsafe integers appear, fix those findings before using the string for hash, hash-based message authentication code (HMAC), or detached-signature preparation.
Convert an array to records
An array such as [{"id":1},{"id":2}] with NDJSON mode set to array mode produces two lines, one compact JSON value per item. If the root value is not an array, the line stream is one compact line for the whole value.
Point to a nested field
For {"items":[{"sku":"A-1"}]}, the Node Ledger gives both a dot-style path such as $.items[0].sku and a JSON Pointer such as /items/0/sku. Use the ledger when a teammate needs an exact field reference instead of a screenshot.
FAQ:
Does it repair invalid JSON?
No. It reports the parse error and waits for valid input. Comment mode can strip comments, but it does not infer missing commas, quote field names, or repair broken structure.
Is Signature Canonical the same as RFC 8785 canonical JSON?
No. It is a sorted local serialization without extra whitespace for repeatable comparison. Use the receiver's RFC 8785 or signing rules when a formal canonical format is required.
When does Line Stream create multiple lines?
Array mode creates one JSON value per line only when the parsed root is an array. Single-line mode always emits one compact JSON value for the whole root.
Why are large integers warned about?
Common browser number handling cannot represent every large whole number exactly. Quote values such as account IDs, snowflake IDs, and long counters when exact digits matter.
Can a valid result still fail in another system?
Yes. A valid JSON result can still fail schema checks, application rules, authentication checks, canonicalization rules, or receiver-specific limits.
Glossary:
- JSON Pointer
- A slash-based standard for pointing to a location inside a JSON value.
- Duplicate member name
- The same object name appearing more than once inside one JSON object.
- Safe integer
- A whole number that common browser number handling can represent and compare exactly.
- Line Stream
- The result view that emits one compact JSON value per line when array mode applies.
- Deterministic serialization
- A repeatable text representation that produces the same bytes for the same parsed data and settings.
References:
- The JavaScript Object Notation (JSON) Data Interchange Format, RFC Editor, December 2017.
- JSON Canonicalization Scheme (JCS), RFC Editor, June 2020.
- JSON Lines format documentation, JSON Lines.
- Number.MAX_SAFE_INTEGER, MDN Web Docs.