JSON Tips & Guides

Practical articles for developers working with JSON, YAML, and API data.

5 min read

Unexpected Token < in JSON at Position 0: You Got HTML

The "Unexpected token <" error means JSON.parse received an HTML page (a 404, login redirect, or wrong URL), not JSON. Here's why, with broken/fixed fetch examples.

Read article →
5 min read

Unexpected Token u in JSON at Position 0: Parsing undefined

The "Unexpected token u" error means you called JSON.parse(undefined). Learn why undefined becomes "undefined", how to guard against it, and a safe-parse helper.

Read article →
5 min read

Unterminated String in JSON: Causes and Fixes

An unterminated string in JSON means an opening quote has no closing quote — usually an unescaped quote, a raw newline, or truncated data. Broken and fixed examples.

Read article →
5 min read

Bad Escaped Character in JSON: Valid Escapes and Fixes

A bad escaped character in JSON means a backslash is followed by something JSON does not allow. See the full list of valid escapes, plus fixes for \x, paths, and \u.

Read article →
5 min read

Unexpected Non-Whitespace Character After JSON Data: Fixes

This error means there is extra content after a complete JSON value — concatenated objects, NDJSON parsed as one blob, or trailing junk. How to find and fix the extra data.

Read article →
5 min read

JSON Pretty Print vs JSON Format: What's the Difference?

Pretty print, format, and beautify mean the same thing for JSON. Learn why, what actually differs (minify, validate, tree view), and how to pretty print JSON online.

Read article →
6 min read

JSON Tree Viewer: Explore JSON as a Collapsible Tree

See JSON as an interactive, collapsible tree. Expand and collapse any object or array to navigate large, nested payloads — in your browser, with no upload.

Read article →
6 min read

YAML Formatter: Format, Re-Indent, and Validate YAML

A YAML formatter re-indents and normalizes YAML so it is readable and diff-friendly. Learn the indentation rules, type traps, and when to format vs convert to JSON.

Read article →
8 min read

XML to JSON Conversion: Attributes, Text Nodes, Arrays, and Namespaces

Convert XML to JSON the right way: how attributes, text nodes, repeated elements, and namespaces map to JSON — with conventions, edge cases, and JS/Python code.

Read article →
7 min read

JSON to XML: Root Elements, Arrays, and Attribute Mapping

Convert JSON to XML: choosing a root element, mapping @-prefixed keys to attributes, turning arrays into repeated elements, and escaping — in JS, Python, and online.

Read article →
7 min read

How to Convert JSON to CSV (and Back)

Convert JSON to CSV and CSV to JSON — in JavaScript, Python, and online. Covers the array-of-objects mapping, quoting rules, nested values, and type coercion.

Read article →
8 min read

How to Validate JSON: Syntax and Schema Validation

Validate JSON syntax with JSON.parse, Python's json.loads, jq, or in your browser — and learn how to check structure and types with JSON Schema.

Read article →
8 min read

How to Stringify JSON with JSON.stringify

JSON.stringify converts a value to a JSON string. Learn the space and replacer arguments, the toJSON hook, and the values it silently drops or throws on.

Read article →
7 min read

JSON vs YAML: Differences and When to Use Each

JSON vs YAML compared: syntax, types, comments, and gotchas like the Norway problem. YAML is a JSON superset — here's when to use each and how to convert.

Read article →
8 min read

How to Decode a JWT and Read Its Claims

A JWT is three Base64url sections. Learn how to decode the header and payload in JavaScript and Python — and why decoding a token is not the same as verifying it.

Read article →
7 min read

JSON Patch vs JSON Merge Patch: RFC 6902 vs 7396

JSON Patch (RFC 6902) sends explicit operations; JSON Merge Patch (RFC 7396) overlays a partial object. Compare both with examples and pick the right one.

Read article →
7 min read

How to Convert CSV and XML to JSON

Convert CSV and XML to JSON in JavaScript, Python, and the browser. Covers the array-of-objects mapping, XML attribute handling, and the type-coercion gotchas.

Read article →
7 min read

jq Tutorial: Filter and Transform JSON

A practical jq tutorial: install it, pretty-print and minify, select fields, filter arrays with select, transform with map, plus copy-paste command recipes.

Read article →
10 min read

How to Generate TypeScript Interfaces from JSON

Learn how to convert JSON to TypeScript interfaces — manually, with online tools, and in code. Covers nested objects, optional fields, arrays, nullable types, and keeping types in sync with your API.

Read article →
10 min read

What Is JSON Schema? A Practical Guide with Examples

JSON Schema is a vocabulary for describing the structure and constraints of JSON data. Learn the core keywords, see real-world examples, and validate JSON in JavaScript, Python, and your browser.

Read article →
9 min read

How to Minify JSON — and When You Should

Minifying JSON removes all unnecessary whitespace to reduce file size and speed up API responses. Learn how to minify JSON in JavaScript, Python, the command line, and your browser — and when not to bother.

Read article →
8 min read

JSON Viewer vs JSON Formatter: What's the Difference?

JSON viewers and JSON formatters look similar but serve different purposes. Learn when to use each tool, what features to look for, and how to choose the right one for your workflow.

Read article →
9 min read

Fix "[object Object] is Not Valid JSON" and Other JSON Syntax Errors

Getting "[object Object] is not valid JSON" or "expected a JSON object, array or literal"? Learn why these errors happen, how to correct JSON syntax, fix trailing commas, and repair broken JSON automatically.

Read article →
7 min read

Fix JSON Online: Repair, Validate & Format Invalid JSON

Trailing commas, single quotes, unquoted keys, Python literals, markdown fences — online JSON fixers handle them all. Learn how repair parsers work, when to use them, and how to keep sensitive data private.

Read article →
6 min read

JSON Format Examples: Objects, Arrays & Real-World Patterns

Copy-pasteable JSON examples covering every data type, nested structures, REST API responses, config files, date formats, and GeoJSON — with common error patterns and their fixes.

Read article →
8 min read

How to Format JSON: Pretty-Print, Validate, and Clean JSON Files

Format JSON with JSON.stringify in JavaScript, json.dumps in Python, jq on the command line, or instantly in your browser. Includes sorting keys, converting YAML and CSV to JSON, and real before/after examples.

Read article →
7 min read

What Is JSON? A Complete Guide to JSON Format, Syntax, and Files

JSON (JavaScript Object Notation) is the universal data interchange format. Learn the six data types, the grammar rules that make JSON strict, where .json files are used, and how to parse JSON in any language.

Read article →
7 min read

Why You Shouldn't Paste Sensitive JSON Into Online Tools

JWT tokens, API keys, PII, and database exports are routinely pasted into online formatters. Here's what happens to that data on the server side — and why browser-native tools are the safer choice.

Read article →
6 min read

Bad Control Character in String Literal in JSON: Fixes

Raw tabs, newlines, null bytes, and ANSI escape codes inside a JSON string trigger this error. Learn why the JSON spec forbids them, how they sneak in, and how to strip or escape them.

Read article →
5 min read

Unexpected Token o in JSON at Position 1: Causes and Fix

That lowercase "o" is the second character of "[object Object]". You passed a JavaScript object to JSON.parse() instead of a string. Here's every variant of this mistake and the one-line fix for each.

Read article →
5 min read

Unexpected End of JSON Input: Why It Happens and How to Fix It

The parser hit the end of the string before the structure was complete. Causes range from truncated API responses to unclosed brackets and empty strings. Five patterns, five fixes.

Read article →
7 min read

Base64 Is Not Encryption: A Common Developer Misconception

Base64-encoded strings look scrambled, but anyone can decode them in one function call. Learn what Base64 actually is, why it gets confused with encryption, and what to use when you genuinely need to protect data.

Read article →
9 min read

How to Compare Two JSON Files: Algorithms and Tools

A plain text diff misses key-reordering and whitespace noise. Learn how a proper JSON diff works: LCS line diffing, semantic tree comparison, key normalisation, and the tradeoffs of each approach.

Read article →
7 min read

JSON vs JavaScript Object: Why Single Quotes Aren't Allowed

Many developers treat JS object literals as JSON. They're not the same: single quotes, unquoted keys, trailing commas, undefined, NaN — here's every difference with examples.

Read article →
6 min read

Trailing Comma in JSON: Why { "a": 1, } Throws an Error

A single stray comma after the last item in a JSON object or array causes a SyntaxError. Learn why JSON forbids trailing commas, where they come from, and how to remove them.

Read article →
6 min read

How to Fix JSON.parse 'Unexpected Token' Errors

"Unexpected token '<'" or "Unexpected token u in JSON at position 0" — these errors stop your app cold. Here's what each variant means and exactly how to fix it.

Read article →
8 min read

How to Handle Broken JSON in JavaScript

JSON.parse() is unforgiving — one stray comma and your app crashes. Learn the most common broken-JSON patterns, how to catch errors gracefully, and when automatic repair is safe.

Read article →
7 min read

JSON.parse Source Access: Lossless Numbers and Safer LLM Output

The reviver's new context.source argument plus JSON.rawJSON() lets you parse 64-bit IDs without precision loss, verify canonical form, and lock down LLM JSON output — all at native speed. A practical walkthrough now that the API is Baseline 2025.

Read article →