Converter tool

Fine-Tuning JSONL Validator

Check a chat or prompt-completion JSONL training file for broken lines, wrong roles, empty messages and duplicates, then split it into train and validation files.

The checks follow commonly documented chat fine-tuning layouts and are not a guarantee that a provider will accept the file; check the provider's current documentation. Estimated from characters and words: about 4 characters or 0.75 words per token for most languages, and about 1 token per Chinese, Japanese or Korean character. Real counts depend on the model's tokenizer. The text is checked by this browser tab; valid lines are held in memory only so you can download the split.

Preview

Output Preview

Choose a file or paste lines to see the line count, errors, token estimates and duplicates here.

Fine-Tuning JSONL Validator

Operator: Abdulla Al Fahad. How tools are built and checked

A fine-tuning job that fails on line 8,412 of a 20,000-line file is an annoying way to learn that one example had no assistant reply. This validator reads the training file the way a strict importer would, one line at a time, and tells you which lines are broken and why before you upload anything.

It understands two layouts: chat lines shaped like {"messages":[...]}, and older prompt and completion lines. For each file you get a count of lines, valid lines, errors and warnings, a list of the first 200 problems with their line numbers, an estimated token range per example, a count of exact duplicates, and an optional seeded split into train and validation files.

Key features

  • Chat preset and prompt and completion preset
  • Line numbers for every error and warning, capped at the first 200 shown
  • Roles, empty content, system placement, final assistant turn and weight checks
  • Estimated token minimum, average, maximum and total, with a limit you set
  • Exact duplicate lines reported with the line they repeat, and left out of the split files by default
  • Seeded train and validation split of the valid lines, downloaded as two files
  • Files read in pieces, up to 100 MB; no combined copy of the whole text is built for checking

What each preset checks on every line

JSONL means one complete JSON object per line, with no commas between lines and no wrapping array. Blank lines are skipped and counted separately. A leading UTF-8 byte-order mark is stripped from the first line, and a file that starts with a UTF-16 mark is decoded as UTF-16.

In the chat preset each line must be an object with a non-empty messages array. Every message needs a role of system, user, assistant or tool and content that is a string or an array of text parts. A system message is allowed only in first position, there must be at least one user message, and the final message must come from the assistant. Two user or two assistant messages in a row are reported as a warning, because most guides expect turns to alternate. When an assistant message carries a weight, it must be 0 or 1. Assistant messages that have tool calls may leave content empty. Keys other than messages, tools, functions and parallel_tool_calls produce a warning.

In the prompt and completion preset each line needs a non-empty string prompt and a non-empty string completion, and any other key is a warning. These checks follow commonly documented layouts; providers revise their rules, so read the current fine-tuning guide for the service you use.

How it works

A file is read as a stream. The decoder is fed chunks, the text is cut at newline characters, and each finished line goes straight to the checker, so a 90 MB file is never turned into one giant string. Pasted text is checked the same way after splitting on newlines.

Each line is parsed with JSON.parse. A parse failure, a non-object value or a missing field becomes an error for that line number, and a line with any error is left out of the valid set. Warnings do not exclude a line.

Token numbers come from a character and word estimate, not from any model's tokenizer, so they are shown as estimates with the method note beside them. Only the message text counts; role names and JSON punctuation are not included. Use the numbers to spot outliers, not to bill or budget exactly.

For the split, valid lines (minus exact duplicates, unless you turn that option off) are shuffled with a small seeded generator and the first share goes to validation. The same seed and the same lines always produce the same two files, and each file keeps the original line order.

When to run it

  • Checking a support-chat export before building a tone-of-voice training set
  • Finding the one line with a stray trailing comma in a file assembled by a script
  • Spotting examples far above your length limit before they are rejected
  • Keeping repeated lines from two concatenated exports out of the split, so the same example cannot land in both train and validation
  • Producing a repeatable 90/10 split to share with a teammate

Running a check

  1. Pick the line format that matches your data: chat or prompt and completion.
  2. Choose the JSONL file, or paste lines into the box and press Check pasted text. Use sample lines to see what the report looks like.
  3. Set a token limit if your provider caps example length; 0 switches the check off.
  4. Read the summary, then work down the problem list from the top. Fix the source and check again.
  5. When the file is clean, set the validation percentage and a seed, and download the train and validation files.

Example

Four lines (paste as shown) checked in the chat preset

{"messages":[{"role":"user","content":"Hi"},{"role":"assistant","content":"Hello"}]}
{"messages":[{"role":"user","content":"Hi"}]}
{"messages":[{"role":"user","content":"Hi"},}
{"messages":[{"role":"user","content":"Hi"},{"role":"assistant","content":"Hello"}]}

Report

Lines checked 4, valid 2, errors 2, warnings 1
Line 2 error: The last message must be from the assistant.
Line 3 error: Not valid JSON.
Line 4 warning: Identical to line 1 (left out of the split files).

Tips for best results

  • Fix errors from the top of the list; one unclosed quote can cause several later complaints on the same line.
  • Treat warnings as questions. Two assistant messages in a row is sometimes intended, but often a merge mistake.
  • Write down the seed you used so a colleague can regenerate the same split.
  • Look at the maximum token estimate first; one pasted document can dwarf the rest.

Limits

A valid report is not a promise that a provider will accept the file. Rules differ between services and change over time.

Token estimates can differ noticeably from a real tokenizer, especially for code, emoji or short messages.

Duplicates are matched on the exact trimmed line. Two examples that differ by one space are not flagged. With the removal option on, only the first copy of a repeated line goes into the split files; turn it off to keep every valid line.

Only the first 200 problems are listed. The totals still count all of them, so fix the early ones and check again.

The split uses valid lines only, so the two files will hold fewer lines than the original if errors were found.

Common errors and how to fix them

"Not valid JSON."
Open the numbered line in a text editor. Common causes are a trailing comma, a quote that was never closed, single quotes instead of double quotes, or a long line that was wrapped in two.
"The last message must be from the assistant."
The training example ends on a user turn, so there is no answer to learn from. Add the assistant reply or remove the line.
"This file contains NUL bytes"
The file is probably a spreadsheet or archive saved with a .jsonl name. Export the data as plain JSON Lines and choose that file.

Best practices

  • Validate after every script change that writes the file, not just once at the end.
  • Keep a copy of the unsplit valid file alongside the train and validation files.
  • Read ten random lines by eye as well; structure checks cannot judge whether an answer is any good.

Why the duplicate check matters

Say 400 of your 5,000 lines are repeats of the same greeting exchange. In training they carry the same weight as 400 distinct examples, which can push the tuned model toward that one reply. The report lists the later copies with the line they repeat, so you can delete them or decide to keep them on purpose.

Frequently asked questions

Is my training data uploaded?

No. The file is read and checked inside this browser tab. Valid lines are kept in the tab's memory so the split can be downloaded, and they are gone when you close or reload it.

Why are the token counts only estimates?

Each model has its own tokenizer, and this site does not ship those vocabularies. The figures come from a character and word formula and should be read as approximate.

Can it fix the broken lines?

No. It reports problems and lets you download the valid lines as train and validation files, but it does not rewrite content.

How large a file can I check?

Up to 100 MB. Valid lines are kept in memory for the split, so very large files need a browser with enough free memory.