Data formats
JSONL format: rules and examples
Quick answer
A valid JSONL file is UTF-8 text where each line holds exactly one JSON value and lines end with a newline (\n; \r\n is tolerated by most tools). Records are not separated by commas and the file is not wrapped in brackets.
By SourceX Editorial · Updated
The rules#
- UTF-8 encoding.
- One complete JSON value per line — almost always an object.
- Lines separated by \n. A trailing newline at the end of the file is recommended.
- No commas between lines and no outer [ ].
- Newlines inside text are escaped as \n, never written literally.
Example: support tickets#
- {"ticket_id": "00042", "channel": "email", "subject": "Refund request", "resolved": true}
- {"ticket_id": "00043", "channel": "chat", "subject": "Password reset", "resolved": false}
Example: chat fine-tuning records#
Many chat fine-tuning formats use one conversation per line with a messages array. Field names vary by provider, so confirm against their current documentation.
- {"messages": [{"role": "user", "content": "Is this in stock?"}, {"role": "assistant", "content": "Yes, two left."}]}
Common mistakes#
- Pretty-printing records across several lines.
- Single quotes instead of double quotes.
- Trailing commas after the last field.
- Wrapping the file in [ ] like a JSON array.
- Saving as UTF-16 or with stray characters from a spreadsheet export.
Keeping records consistent#
JSONL itself does not require every line to have the same fields. For datasets you usually want that, which is what a JSON Schema check is for.
Try it in your browser
Free tools. Your file is processed in this browser and not uploaded.
Frequently asked questions
Does every JSONL line need the same fields?
Not by the format, but most datasets should. Use the JSON Schema validator to enforce required fields and types.
Can JSONL lines be arrays or numbers?
Yes, any JSON value is allowed, but objects are by far the most common and what most tools expect.
Sources
Related
Tell us what your models need
Share scope, volume, language, format, timing and licensing requirements.