Frequently Asked Questions
Common questions about JSON formatting, repair, validation, and data safety.
Frequently asked questions
- Can I format invalid JSON online?
- Yes. Paste the broken JSON and click Repair & Format. The tool tries to fix single quotes, trailing commas, missing quotes in JSON keys, comments, and Python-style values before formatting the repaired output.
- How do I format broken JSON?
- Start with the smallest safe sample, repair the syntax, then validate the result with a strict JSON parser. If the payload contains trailing commas, this can format JSON with trailing commas by removing the final comma first and formatting the valid result.
- What does Unexpected token mean?
- It means the parser found a character that cannot appear at that position in strict JSON. A single quote, slash, trailing comma, or uppercase
Trueoften points to almost-JSON copied from JavaScript, Python, or an AI response. - Can I convert JSON to a JavaScript object?
- Yes. Once the input is valid JSON, use
JSON.parse(jsonText)in JavaScript. If the text is a JavaScript object literal, repair it into strict JSON before parsing. - Is my data safe?
- Yes. This tool runs entirely in your browser using JavaScript. No data is ever sent to any server.
- What is the difference between Repair and Validate?
- Repair tolerates common mistakes and attempts to produce valid JSON. Validate uses a strict parser and reports the exact line and column of any error.
Detailed usage guide
Most JSON formatter tools stop when a parser throws an error. This one is built for the step before normal formatting: it turns almost-JSON into strict JSON, then prettifies the result so you can review the structure. That makes it useful when you are searching for how to format broken JSON instead of only how to pretty-print a valid response.
Start with the smallest piece of broken JSON you can safely paste. Click Repair & Format when the text came from a JavaScript object literal, Python snippet, markdown response, hand-edited config, or log output that looks like JSON but fails in a strict parser. The repair pass attempts to normalize common syntax mistakes into valid JSON, then prints the result with predictable indentation so nested arrays and objects are easier to review.
After repair, click Validate. Validation uses a strict parser and should be the last check before copying the output into an API client, application config, database migration, test fixture, or command-line example. If validation fails, read the line and column, inspect the highlighted token, and compare the input against the repaired output. Repair is meant to clean up syntax, not to decide whether the values themselves are semantically correct for your application.
Use Minify only after the JSON is valid. Minified JSON is useful for environment variables, query parameters, compact logs, and small examples embedded in documentation. For code review, debugging, and API testing, the formatted output is usually safer because every object key, array item, and nested value is on a predictable line.
JSON error dictionary
- Trailing comma
- A final comma before
}or]is accepted by many JavaScript tools but rejected by JSON parsers. Remove the final comma after the last property or array item. - Missing quotes in JSON keys
- Object keys such as
nameandactivemust be wrapped in double quotes. Convert{ name: "Ada" }to{ "name": "Ada" }. - Single quotes
- JSON strings require double quotes. Replace
'Ada'with"Ada", and be careful with apostrophes inside string values. - Unexpected token
- This parser message means a character appeared where strict JSON grammar did not allow it. The token may be a comma, slash, single quote, uppercase boolean, or extra text after the JSON document.
- Python literals
- Python uses
True,False, andNone. JSON usestrue,false, andnull. - Comments
- Comments are common in JavaScript and JSONC, but not valid JSON. Remove
//line comments and/* block comments */before sending data to a JSON parser. - Markdown code fences
- LLM responses often wrap JSON in
```jsonfences. Remove the fence markers before parsing or sending the payload to an API.
Per-tool questions
- JSON Fix — How do I repair invalid JSON?
- Paste the broken JSON into JSON Fix, click Repair & Format. It fixes trailing commas, single quotes, unquoted keys, Python literals, comments, and markdown code fences in one pass.
- JSON Validate — What is the difference between validating and parsing JSON?
- Parsing turns the JSON into a usable value; validating just confirms it could be parsed. A successful
JSON.parseis the validation — see JSON Validator. - JSON Viewer — Why is my tree empty?
- A tree can only be built from parseable JSON. Repair common errors first with JSON Fix, then load the cleaned result into the JSON Viewer.
- JSON Diff — Why are sorted and unsorted versions reported as identical?
- JSON objects are unordered by spec. JSON Diff normalises keys before comparing, so only real value differences appear.
- JSON to TypeScript — Are the generated types validated at runtime?
- No. JSON to TypeScript generates compile-time interfaces. For runtime validation, pair them with Zod or describe the shape with JSON Schema.
- JSON Minify — How much does minifying save?
- Typically 15–50% before HTTP compression. If your server already sends
Content-Encoding: gziporbr, the marginal saving from minify is small. - JSON Stringify — How do I decode a double-encoded JSON string?
- Click Unstringify in JSON Stringify, or call
JSON.parsetwice if the input starts with an escaped quote. - JSON ⇄ CSV — How are nested objects represented?
- Each nested object or array is written as JSON text inside the cell, keeping the conversion reversible. See JSON to CSV.
- JSON ⇄ XML — How do I make a value an XML attribute?
- Prefix the key with
@(e.g.@id); element text goes under#text; arrays become repeated elements. See JSON to XML. - YAML — Why does my YAML fail to parse?
- Almost always indentation — a tab character (YAML forbids tabs) or misaligned siblings. Run it through the YAML formatter, which surfaces and normalises both.
- Base64 — What is the difference between Base64 and Base64url?
- Standard Base64 uses
+and/with=padding; URL-safe Base64url replaces them with-and_and drops padding so the value is safe in URLs and JWTs. See Base64. - URL Decode — Why does my
+not decode to a space? - In query strings, a space may appear as
+(form encoding) or%20.decodeURIComponentdoes not turn+into a space — replace it first if you have form-encoded data. See URL Decode. - JWT Decode — Does this verify the signature?
- No. JWT Decode reads the claims; it does not check the signature. Always verify server-side, and configure your library with the exact algorithm you expect (never accept
alg: none).
Which error article do I need?
If you have an exact error string, jump directly to its dedicated article:
- "Unexpected token < in JSON at position 0" → your fetch returned HTML
- "Unexpected token u in JSON at position 0" → you parsed
undefined - "Unexpected token o in JSON at position 1" → an object was stringified to
[object Object] - "Unexpected end of JSON input" → truncated or unclosed structure
- "Unexpected non-whitespace character after JSON data" → extra data after a complete value (NDJSON?)
- "Unterminated string in JSON" → a string opened but never closed
- "Bad escaped character in JSON" → invalid backslash escape (e.g.
\x, Windows paths) - "Bad control character in string literal in JSON" → raw tab/newline/control byte inside a string
- "Expected double-quoted property name…" → trailing comma
- "[object Object] is not valid JSON" → object stringified before parsing
- Not sure which? → start at the overview: How to Fix JSON.parse Unexpected Token Errors
How local processing protects privacy
The repair, validation, formatting, minification, and copy actions run in your browser tab. The tool does not need an upload endpoint to process your JSON. That matters for API samples, webhook payloads, internal config snippets, or debugging output that may contain private identifiers. You should still remove secrets before pasting examples into any website, but this tool is designed so the core JSON workflow is local-first.
The site may use hosting logs, analytics, and advertising scripts around the page, as described in the privacy policy. Those systems should not receive the content you paste into the editor for repair. If a payload contains credentials, access tokens, customer records, or production secrets, replace those values with safe placeholders before debugging.
What JSON is and why it is strict
JSON stands for JavaScript Object Notation, but modern JSON is language-independent. Python, Go, Java, PHP, Ruby, Rust, databases, queues, log systems, and browser code can all read the same JSON document because the grammar is deliberately small. That strictness is useful: a JSON parser does not execute functions, constructors, dates, comments, or expressions. It only accepts data.
The tradeoff is that text copied from a JavaScript object literal, Python dictionary, TypeScript config, or markdown answer may look familiar while still being invalid JSON. Repair helps convert that almost-JSON into data that a strict parser can accept.
Before using repaired JSON
A successful repair means the text can be converted into valid JSON syntax. It does not prove that the payload is correct for your endpoint or application. Before using repaired JSON in production, check required fields, unknown keys, value types, array lengths, date formats, enum values, null handling, and whether identifiers should be strings or numbers.
If the payload controls permissions, billing, data deletion, or customer-visible behavior, compare it against a known-good sample or schema after repair. For API work, validate syntax first, then validate the business contract.
JSON repair guides
Topic hubs
- JSON Parse Errors: Read the Message, Jump to the Fix
- Fix Invalid JSON: From 'What's Wrong' to a Clean File
- JSON Formatter, Validator, Viewer: Pick the Right Tool
- Repair LLM JSON Output: Handling Almost-JSON from AI
- Privacy: JSON Tools That Don't Leave Your Browser
- JSON Interop: YAML, CSV, XML, JWT, Schema
Specific guides
- How to Decode Base64 Strings (and JWT Payloads)
- URL Encoding: Percent-Encode Query Parameters and Paths
- Convert YAML to JSON (and Avoid Indentation Errors)
- Convert JSON to CSV: Flatten an Array of Objects
- Convert JSON to XML: Root Elements, Attributes, and Arrays
- Escape JSON as a String Literal (and Decode Double-Encoded JSON)
- Fix Trailing Comma in JSON
- Fix Single Quotes in JSON
- Fix Unquoted Keys in JSON
- Repair LLM JSON Output
- Fix JSON Parse Error: Expected Property Name
- JSON vs JS Object Literal: The Key Differences
- Validate JSON Before API Requests
- JSON Formatter vs JSON Repair
- Fix JSON Unexpected Token Errors
- JSON to JavaScript Object Converter