JSON Tips & Guides

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

Unexpected Token < in JSON at Position 0: Fix HTML Responses in fetch()

Fix Unexpected token < in JSON at position 0 by proving whether fetch() returned HTML: 404 pages, login redirects, SPA fallbacks, dev proxies, WAF blocks, and wrong API URLs.

12 min read

Unexpected Token u in JSON at Position 0: Fix JSON.parse(undefined)

Fix Unexpected token u in JSON at position 0 by finding the undefined value passed to JSON.parse(): missing props, localStorage mistakes, async state, no-return functions, env vars, and unsafe fallbacks.

10 min read

Unterminated String in JSON: Causes and Fixes

Fix unterminated JSON strings by finding the open quote, escaped closing quote, raw newline, or truncated response that left the value incomplete.

12 min read

Bad Escaped Character in JSON: Causes, Examples, and Fixes

Fix "bad escaped character in JSON" errors from \x escapes, Windows paths, regex strings, malformed \u values, and double-encoded JSON.

12 min read

Unexpected Non-Whitespace Character After JSON: Fixes

Why JSON.parse read one value and then failed on extra data, plus fixes for concatenated objects, NDJSON, logs, fetch responses, and framed streams.

12 min read

JSON Pretty Print vs Format: Same Output, Different Workflows

Pretty print, format, and beautify mean the same JSON operation. Learn the practical differences around validation, repair, minify, key sorting, tree view, CLI tools, numeric precision, and safe formatting.

11 min read

JSON Tree Viewer: Explore Nested JSON Without Getting Lost

Use a JSON tree viewer to inspect large API responses, collapse noisy branches, read object and array paths, handle invalid JSON, compare shapes, and keep sensitive payloads local.

10 min read

YAML Formatter: Re-Indent and Validate

Format YAML without hiding config bugs: fix indentation, catch parser errors, handle anchors, comments, type coercion, sorting, and YAML-to-JSON output.

13 min read

XML to JSON: Attributes, Arrays & Namespaces

Convert XML to JSON without losing shape: attributes, text nodes, repeated elements, namespaces, CDATA, entities, type coercion, and code examples.

13 min read

JSON to XML: Convert Online, JavaScript, and Python Without Losing Shape

Convert JSON to XML with practical rules for root elements, attributes, #text, arrays, namespaces, invalid tag names, escaping, XSD order, null values, types, JavaScript, Python, and browser-local tools.

12 min read

How to Convert JSON to CSV Without Losing Columns or Types

Convert JSON to CSV and back with practical rules for headers, quoting, nested objects, type coercion, Excel imports, and browser-local conversion.

11 min read

How to Validate JSON: Syntax, Schema, CI Checks, and Real Error Messages

Validate JSON syntax with JSON.parse, Python json.loads, jq, or a browser-local validator, then use JSON Schema for required fields, types, formats, and API contract checks.

12 min read

How to Stringify JSON with JSON.stringify: Values, Replacer, Space, and Escaping

Learn how JSON.stringify works in real JavaScript code: request bodies, pretty-printing, replacer functions, toJSON, BigInt, Map, Set, circular references, and JSON string literals.

12 min read

JSON vs YAML: When to Use Each for APIs, Config, and CI

JSON vs YAML explained with practical examples for APIs, app config, Kubernetes, CI pipelines, type inference, comments, anchors, conversion, parser safety, and browser-local validation.

12 min read

How to Decode a JWT Safely: Header, Payload, Claims, and Verification

Decode a JWT locally, read header and payload claims, handle Base64url and Unicode safely, and understand why decoding is not signature verification.

11 min read

JSON Patch vs JSON Merge Patch: RFC 6902 vs RFC 7396 for API Partial Updates

Choose between JSON Patch and JSON Merge Patch with concrete API examples: null handling, arrays, JSON Pointer paths, test operations, ETags, validation, idempotency, and server-side safety checks.

12 min read

How to Convert CSV and XML to JSON Without Losing Shape

Convert CSV and XML to JSON with practical mapping rules for headers, types, attributes, repeated elements, namespaces, and browser-safe validation.

11 min read

jq Tutorial: Practical Examples, Filters, and a Copy-Paste Cheat Sheet

Learn jq with copy-paste commands for pretty-printing JSON, extracting fields, filtering arrays, reshaping API responses, passing shell variables, validating files, and exporting CSV.

12 min read

JSON to TypeScript Interfaces: Generate Types That Survive Real APIs

Generate TypeScript interfaces from JSON samples safely. Learn when to use an online converter, quicktype, OpenAPI, Zod, multiple samples, optional fields, nullable values, arrays, enums, dates, and runtime validation.

13 min read

What Is JSON Schema? Validation & Examples

What JSON Schema is, how validation works, the core keywords, draft 2020-12 examples, Ajv/Python validation, and mistakes to avoid.

15 min read

How to Minify JSON: JavaScript, Python, jq, and When It Is Worth It

Minify JSON with JSON.stringify, Python json.dumps, jq, or a browser-local tool. Learn what changes, what does not, how compression affects savings, and when readable JSON is better.

11 min read

JSON Viewer vs JSON Formatter: Which Tool Should You Use?

Compare JSON viewers and JSON formatters with practical examples for API debugging, large payloads, DevTools, jq, Prettier, diffs, repair workflows, and browser-local privacy.

11 min read

Fix "[object Object] is Not Valid JSON": Causes and Safer Syntax Fixes

Fix "[object Object] is not valid JSON" by finding where a JavaScript object was coerced to a string, then handle the related JSON syntax errors safely.

11 min read

How Online JSON Repair Works: Rules, Limits, and Safer Fixes

Learn how online JSON repair tools fix trailing commas, single quotes, unquoted keys, comments, Python literals, and LLM code fences without hiding risky data changes.

10 min read

JSON Format Examples: Valid Objects, Arrays, API Responses, Config Files, and Edge Cases

Copy valid JSON examples for objects, arrays, API responses, config files, dates, nulls, escaped strings, JSON Lines, OpenAPI, GeoJSON, and common syntax mistakes.

11 min read

How to Format JSON Safely: Pretty-Print, Sort Keys, and Avoid Data Changes

Format JSON with JSON.stringify, Python json.dumps, jq, Prettier, VS Code, or a browser-local tool, with examples for indentation, sorting keys, validation, and safe workflows.

11 min read

What Is JSON? Format, Syntax & Data Types

What JSON is, how the format works, its six value types, strict syntax rules, .json files, parsing, validation, and practical modeling choices.

13 min read

Don't Paste Sensitive JSON Into Online Tools: Use Local Parsers

Sensitive JSON can leak through formatter logs, analytics, caches, tickets, screenshots, and browser extensions. Learn what not to paste, how to verify browser-local tools, and how to redact safely.

12 min read

Bad Control Character in JSON: Fix Raw Newlines, Tabs, NULs, and ANSI Bytes

Fix bad control character JSON errors by finding raw tabs, newlines, carriage returns, NUL bytes, and ANSI escape bytes inside strings, then escaping or removing them safely.

11 min read

Unexpected Token o in JSON at Position 1: Fix [object Object] Parsing

Fix Unexpected token o in JSON at position 1 by finding the object, Response, Promise, Axios result, FormData, localStorage value, or already-parsed JSON that was passed to JSON.parse().

11 min read

Unexpected End of JSON Input: Causes, Fetch Fixes, and Safe Parsing

Fix SyntaxError: Unexpected end of JSON input in JSON.parse(), fetch(), empty 204 responses, localStorage, truncated bodies, unclosed brackets, streams, NDJSON, and production safe parsing.

11 min read

Base64 Is Not Encryption: What It Hides, What It Does Not

Base64 is encoding, not encryption. See why passwords, JWT payloads, API keys, Basic Auth headers, URL data, and logs stay readable after Base64.

15 min read

How to Compare Two JSON Files Without Key-Order Noise

Compare two JSON files by parsing, sorting keys, ignoring formatting noise, and highlighting real added, removed, and changed values.

12 min read

Single Quotes in JSON: Why JavaScript Objects Parse and JSON.parse Fails

Single quotes are valid in JavaScript object literals, not JSON. Compare the exact syntax differences, conversion traps, JSON.stringify behavior, safe repair workflows, and when not to use eval.

12 min read

Trailing Comma in JSON: Why JSON.parse Rejects { "a": 1, }

Fix trailing comma JSON errors in objects and arrays. Learn why JSON.parse rejects final commas, how to find them from parser messages, when JSONC or JSON5 is appropriate, and how to prevent them in CI.

11 min read

Fix JSON.parse Unexpected Token Errors: <, u, o, Quotes, Commas, Comments, and HTML

Diagnose JSON.parse unexpected token errors by the first token you received: HTML, undefined, [object Object], single quotes, trailing commas, comments, Python literals, BOMs, NaN, or truncated JSON.

12 min read

How to Handle Broken JSON in JavaScript: Parse, Repair, Validate

Handle broken JSON in JavaScript with safer JSON.parse wrappers, fetch response checks, localStorage guards, jsonrepair workflows, error positions, schema validation, and browser-local repair.

13 min read

JSON.parse Source Access: context.source, BigInts, JSON.rawJSON, and LLM JSON

Use JSON.parse reviver context.source and JSON.rawJSON safely: feature-detect support, rescue large numeric IDs, serialize BigInts, and harden repaired LLM JSON output.

12 min read