Runs in your browser · nothing is uploaded
JSON Formatter & Validator
Paste JSON into this JSON formatter to pretty-print it with your choice of indent, minify it, check it's valid, convert it to YAML or back, pull out one value by dot path, or explore it as a collapsible tree.
Path lookup supports simple dot-separated keys and array indices, not the full JSONPath language.
What each mode does
- FormatJSON.parse(input) → JSON.stringify(value, null, indent), indent 1–8 spaces
- MinifyJSON.stringify(value) with no whitespace outside strings
- Validate"Valid JSON", or the parser's error message and position
- JSON ↔ YAMLYAML 1.2 parser and serializer; YAML → JSON output uses 2-space indents
- Find dot path$.key.0.child — keys and array indexes separated by dots
- Tree viewcollapsible outline: 200 nodes, 30 entries per level, 12 levels deep
Every mode parses the whole input first with the browser's own JSON parser, so the tool is exactly as strict as JavaScript: what passes here will pass JSON.parse in your code. Formatting never changes data — only whitespace. Key order is kept as written, with one JavaScript quirk: keys that look like whole numbers, such as {"b":1,"2":0} → {"2":0,"b":1}, move to the front of their object.
Path lookup supports simple dot-separated keys and array indices, not the full JSONPath language.
Worked example
A one-line order from an API (178 bytes), formatted with a 2-space indent:
{
"order": 1042,
"customer": {
"name": "Ada Park",
"email": "ada@example.com"
},
"items": [
{
"sku": "MUG-01",
"qty": 2,
"price": 12.5
},
{
"sku": "TEA-07",
"qty": 1,
"price": 8
}
],
"paid": true,
"note": null
}That's 21 lines and 285 bytes. Minify brings it back to 178 bytes. As YAML:
order: 1042
customer:
name: Ada Park
email: ada@example.com
items:
- sku: MUG-01
qty: 2
price: 12.5
- sku: TEA-07
qty: 1
price: 8
paid: true
note: null
Dot path lookups on the same data:
- $.customer.name → "Ada Park"
- items.1.sku → "TEA-07"
- $.items.0 → {"sku":"MUG-01","qty":2,"price":12.5}
Common JSON errors and YAML surprises
Why JSON fails to validate
| Problem | Valid? | Fix |
|---|---|---|
| Trailing comma | No | Delete the comma after the last item. |
| Single quotes | No | Use double quotes for keys and strings. |
| Unquoted key | No | Quote every key: "a". |
| Comment | No | Remove comments, or keep them in YAML or JSONC instead. |
| NaN / Infinity | No | Use null or a string; JSON has no NaN or Infinity. |
| Leading zero | No | Write it as a string: "02134". |
| Unescaped line break in a string | No | Write \n inside the string. |
JSON allows only double-quoted strings, the literals true, false and null, numbers without leading zeros, objects and arrays. JavaScript object literals are looser, which is why copying an object out of source code often fails.
How YAML values come out as JSON
| YAML | JSON |
|---|---|
| country: NO | {"country":"NO"} |
| enabled: yes | {"enabled":"yes"} |
| version: 1.10 | {"version":1.1} |
| release: 2026-10-15 | {"release":"2026-10-15"} |
| zip: 02134 | {"zip":2134} |
Under YAML 1.2, used here, NO and yes stay strings — older YAML 1.1 tools turn them into booleans, the well-known "Norway problem". But unquoted numbers still lose detail: 1.10 becomes 1.1 and a leading zero is dropped. Quote version numbers, ZIP codes and IDs in YAML if they must stay exact.
Numbers are parsed as 64-bit floating point, so integers above 2^53 − 1 (9,007,199,254,740,991) can change in the last digits. If a tool on the other end relies on exact large IDs or decimal money values, send them as strings.
Sources: RFC 8259 (The JavaScript Object Notation Data Interchange Format); ECMA-404; YAML Specification 1.2.2 (core schema); ECMAScript Language Specification, JSON.parse and Number.MAX_SAFE_INTEGER; eemeli/yaml documentation. Checked 15 October 2026.
Frequently asked questions
How do I format (pretty-print) JSON?+
Paste it into Input, choose Format, set Indent spaces (up to 8; 2 and 4 are the common styles) and press Generate / convert. The result is re-indented with one key per line. Copy it or download it as a text file.
Why does my JSON say it's invalid?+
The most common causes are a trailing comma after the last item, single quotes instead of double quotes, keys without quotes, comments, and values like NaN, undefined or Infinity — all fine in JavaScript but not allowed in JSON. Validate shows your browser's parser message, which usually includes the position of the first problem.
What does minify do?+
It removes every space and line break outside strings, giving the smallest equivalent JSON for APIs, config values or storage. The data is unchanged: minified and formatted versions parse to exactly the same value.
How do I convert JSON to YAML or YAML to JSON?+
Pick JSON to YAML or YAML to JSON. YAML is read with YAML 1.2 rules, so yes, no, on and off stay as text instead of turning into true and false, and dates stay as strings. Anchors and aliases work, but alias expansion is capped (a limit of 50) to stop "billion laughs" expansion attacks. Comments in YAML are dropped because JSON has no comments.
How does the dot path lookup work?+
Type a path such as $.user.name or items.0.price in the dot path box and choose Find dot path. Each part is an object key or an array index, separated by dots, and the leading $ is optional. Bracket syntax like items[0] and JSONPath filters or wildcards aren't supported, and keys that themselves contain a dot can't be reached.
Why did a large number change after formatting?+
JSON numbers are parsed as JavaScript doubles, which are exact only up to 9,007,199,254,740,991. 9007199254740993 comes back as 9007199254740992. If your data has 64-bit IDs, have the API send them as strings.
What happens with duplicate keys?+
The JSON standard says keys should be unique but doesn't forbid duplicates. This tool keeps the last one: {"a":1,"a":2} becomes {"a":2} after formatting, and the earlier value is silently dropped.
How big a file can the tree view show?+
Format, minify and validate handle anything you can paste (up to 1,000,000 characters). The tree preview is capped to stay fast: 200 nodes, the first 30 entries of each object or array, and 12 levels deep. Use Format or Find dot path to see the rest.
What indent should I use, and what does 0 do?+
Indent spaces defaults to 2, a common style for JSON in web projects; 4 is also popular. Any whole number from 0 to 8 works, and larger numbers are capped at 8. An indent of 0 puts everything on one line, the same as Minify.
Does formatting keep my keys in the same order?+
Mostly. Keys come out in the order they were written, except keys that are whole numbers, which JavaScript always puts first in ascending order: {"b":1,"10":2,"a":3,"2":4} formats as {"2":4,"10":2,"b":1,"a":3}. The values are unchanged; only the order in the text differs.
Can it convert a YAML file with several documents separated by ---?+
No. YAML to JSON reads one document, and a file with more shows a "Source contains multiple documents" error. Paste and convert each document on its own.
Is my JSON uploaded to a server?+
No. Parsing, formatting and YAML conversion all run in your browser, so it's safe to paste API responses or config files. Nothing is sent or stored; downloading the result creates the file on your device.
More free Northlane tools
- JSON diffStructural diff and merge
- JSON to CSVFlatten JSON into a spreadsheet
- Regex testerTest JavaScript patterns with highlights, capture groups and a replacement preview.
- Base64 decodeEncode UTF-8 text or files, decode Base64, and generate file checksums.
- UUID generatorGenerate cryptographically random version 4 UUIDs individually or in bulk.
- Epoch converterConvert seconds, milliseconds, or timezone-qualified dates in batches.
- Meta tag generatorGenerate escaped HTML metadata, canonical, Open Graph and Twitter tags.
- Cron expression generatorBuild five-field cron schedules and preview the next ten runs in a timezone.
- Image to Base64Convert images to data URLs or rasterize a sanitized SVG into PNG locally.
- CSS gradient generatorCreate linear or radial gradients with color stops, opacity, CSS and PNG export.
- All toolsBrowse the full collection