🍋
Menu
Developer

JSON Lines

JSON Lines (NDJSON)

A text format where each line is a valid JSON value, designed for streaming and log processing one record at a time.

Technical Detail

JSON Lines is defined by RFC 8259 and ECMA-404. It supports six data types: string, number, object, array, boolean, and null. JSON numbers have no distinction between integer and float — implementations must handle precision carefully (JavaScript's Number.MAX_SAFE_INTEGER is 2^53 - 1). JSON does not support comments, trailing commas, or single quotes, which are common sources of parse errors. JSON5 and JSONC extend the format with these developer-friendly features.

Example

```javascript
// Parse JSON with error handling
try {
  const data = JSON.parse(rawString);
  console.log(data.name); // access properties
} catch (e) {
  console.error('Invalid JSON:', e.message);
}

// Serialize with formatting
const pretty = JSON.stringify(obj, null, 2);
```

Related Formats

Related Tools

Related Terms