Skip to main content
ArjenSoft4 min readUpdated 2026-11-27

How to format and validate JSON safely

Common RFC 8259 syntax pitfalls, 64-bit integer precision traps in JavaScript, and why local formatting protects sensitive payloads.

Most common JSON syntax errors

Unlike JavaScript object literals, strict JSON (RFC 8259) requires double quotes around all keys and string values, forbids trailing commas after the final item in an array or object, and does not allow inline comments.

  • Single quotes around keys or strings → replace with standard double quotes (").
  • Trailing comma before } or ] → remove the final comma.
  • Unescaped newlines or control characters inside strings → escape as \n or \t.

Watch out for 64-bit integer rounding

Many backend APIs emit 64-bit numeric IDs (such as 9007199254740993). Standard browser JSON.parse converts numbers to IEEE-754 doubles, silently rounding integers beyond 2^53 − 1 (9007199254740991).

The ArjenSoft JSON Formatter scans the raw input text before parsing and alerts you whenever an unsafe integer appears so you can quote it as a string or handle it with BigInt in your codebase.

{
  "safe_id": "9007199254740993",
  "status": "validated"
}