Cheat Sheet
A one-page reference for all JSON5 syntax. Print it, bookmark it, or keep it handy.
Click to open print dialog, then save as PDF
Comments
// Single-line comment /* Multi-line comment */ { key: 'val' } // inlineTrailing Commas
// Objects { a: 1, b: 2, // OK! } // Arrays [1, 2, 3,] // OK!Unquoted Keys
// Valid identifiers { name: 'value', _private: true, $special: 1, } // Quote if needed { 'key-name': 'val' }Strings
// Single or double quotes 'single quotes' "double quotes" // No escaping needed 'He said "hi"' "It's working" // Multi-line 'Line 1 \ Line 2'Numbers
// Standard 42 // integer -17 // negative 3.14 // decimal 1.5e10 // scientific // Extended 0xFF // hex .5 // leading decimal 5. // trailing decimal +10 // explicit positiveSpecial Values
// Booleans & null true false null // IEEE 754 Infinity -Infinity NaNEscape Sequences
'\n' // newline '\t' // tab '\r' // return '\\' // backslash '\'' // single quote '\"' // double quote '\x41' // hex (A) '\u0041' // unicodeObjects
{ unquoted: 'key', 'quoted': 'key', nested: { deep: true, }, }Arrays
[ 1, 'two', { n: 3 }, [4, 5], ]Node.js
// Install npm install json5 // Use import JSON5 from 'json5'; const obj = JSON5.parse(str); const str = JSON5.stringify(obj);Browser
// Via CDN <script src="https://unpkg.com/ json5@2/dist/index.min.js"> </script> // Then use JSON5.parse(str);Config Example
{ // Server settings host: 'localhost', port: 3000, debug: true, cors: [ 'https://app.com', ], }JSON5 is a superset of JSON - all valid JSON is valid JSON5.
Learn more at json5.dev
About This Cheat Sheet
Print Ready
Optimized for printing on a single page. Use "Save as PDF" in your browser.
Complete Coverage
Every JSON5 feature on one page. Comments, strings, numbers, and more.
Always Updated
Matches the official JSON5 specification. Bookmark this page for quick reference.
Want to Learn More?
Check out our tutorials and examples for in-depth learning.