Converter tool

CSV to Chat Fine-Tuning JSONL

Turn question and answer columns into chat-format JSONL training lines, with optional system text, multi-turn grouping and a repeatable train and validation split. Runs in your browser.

Rules differ between providers, so check the current fine-tuning documentation of the one you use before you upload. Cell text is trimmed and rows with an empty user or assistant cell are skipped. This page writes nothing to localStorage, sessionStorage or IndexedDB.

Preview

Output Preview

Load a CSV and pick its columns to see the first JSONL line, counts and token estimates here.

CSV to Chat Fine-Tuning JSONL

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

Support teams keep their best answers in a spreadsheet: one column for what the customer asked, one for what an agent replied. Fine-tuning services that take chat-format training data want the same material as JSONL, a text file with one JSON object per line, each holding a list of role-tagged messages. This page does that reshaping. Choose which column is the user text and which is the assistant text, optionally add a system message, and every usable row becomes one {"messages": [...]} line.

Two options go beyond a straight row-to-line copy. A conversation id column glues consecutive rows into one multi-turn example, and a validation share carves off a held-out file using a shuffle seed you can see and reuse, so the same split can be rebuilt after you fix a typo in the source.

Key features

  • One JSONL line per row, or one line per conversation when a conversation id column is chosen
  • System message taken from a column, typed once for every line, or left out
  • Rows with an empty user or assistant cell skipped, with their row numbers listed
  • Optional validation share from 0 to 50 percent, shuffled with a visible seed
  • Same seed and same file always give the same train and validation files
  • Estimated tokens for the smallest, average and largest line and for the whole file
  • Download as train.jsonl, or as a ZIP holding train.jsonl and validation.jsonl when a split is on

From CSV rows to chat-format lines

The CSV needs column names on its first line, at least one column for what the user says and one for what the assistant should answer. Quoted cells may contain commas and line breaks. Semicolon- or tab-separated files end up as a single column, so save them with commas first. UTF-8 is expected; a UTF-16 file that starts with a byte-order mark is decoded too, and a file with a NUL byte near the start is refused.

Each output line is a JSON object with one key, messages. The list holds an optional {"role":"system"} entry first, then alternating {"role":"user"} and {"role":"assistant"} entries, each with a content string. Text is escaped by JSON.stringify, so quotes, backslashes, tabs and line breaks inside a cell stay inside one physical line. Non-ASCII characters are written as they are, not as \u escapes.

Cell text is trimmed at both ends before use. A row whose user cell or assistant cell is empty after trimming is left out and its row number is listed (the header is row 1). The limits are 25 MB and 100,000 data rows per run.

Providers differ in the roles they accept, in the number of examples they require and in the size limit of a single example. This page does not check your file against any one provider's rules; read the current fine-tuning documentation of the service you plan to use before uploading.

How it works

After the file passes the binary check and the size limit, the CSV is parsed with the same parser the split tools use. The columns named user, prompt, question, input or instruction are pre-selected for the user side, and answer, response, output, completion or reply for the assistant side; change them if the guess is wrong.

Rows are walked in file order. A row with both cells filled starts a new conversation, unless a conversation id column is chosen, the row's id is not empty and it equals the id of the previous row that was kept. Rows skipped for an empty cell do not break a group: if rows 2 and 4 share an id and row 3 was skipped, rows 2 and 4 still join. Ids that return after a different id start a new conversation, because only neighbouring kept rows are grouped. A row with an empty id always stands alone.

The system message of a conversation comes from its first row. With a system column, that row's cell is used; with fixed text, the same string is used for every conversation; if the text is empty, no system message is written.

When the validation share is above zero and there are at least two lines, the number of validation lines is the share of the total, rounded, with at least one line and always at least one left for training. The lines are shuffled by a Fisher-Yates pass driven by a small seeded generator, the first part goes to validation and the rest to training. Order inside each file is the shuffled order.

Each line's size is guessed from the text of all its messages, counting about one token per four characters, a second figure from the word count, and one token per Chinese, Japanese or Korean character. Use the smallest, average and largest figures to spot outliers, not to predict an invoice.

Common use cases

  • Turning a help-desk export of questions and approved replies into training lines for a support assistant
  • Building a small style-transfer set from pairs of rough notes and their polished rewrites
  • Converting a labelled classification sheet, where the assistant cell holds the label, into chat format
  • Rebuilding a multi-turn dataset from a table where each row is one turn and a ticket number ties them together
  • Producing a validation file with a recorded seed so a later retraining uses the identical held-out lines

How to use this tool

  1. Load your CSV, or press Use sample data to see four support questions, one of which has no answer yet.
  2. Pick the user column and the assistant column.
  3. Decide on a system message: none, the same sentence on every line, or a column.
  4. If your rows are turns of longer chats, choose the column that holds the conversation id.
  5. Move the validation slider if you want a held-out file; note the seed, and press New seed for a different shuffle.
  6. Read the counts, the skipped-row list and the token estimates, then press Download.

Example

support.csv with a fixed system text of "You are helpful" (3 rows)

question,answer
How do I reset my password?,Open Settings then Security and choose Reset password.
Can I change my invoice address?,Yes. Edit it under Billing before the 25th.
Do you ship abroad?,

train.jsonl (2 lines; row 4 skipped for an empty answer)

{"messages":[{"role":"system","content":"You are helpful"},{"role":"user","content":"How do I reset my password?"},{"role":"assistant","content":"Open Settings then Security and choose Reset password."}]}
{"messages":[{"role":"system","content":"You are helpful"},{"role":"user","content":"Can I change my invoice address?"},{"role":"assistant","content":"Yes. Edit it under Billing before the 25th."}]}

Tips for best results

  • Read ten random lines of the output before uploading anywhere; a swapped column shows up immediately.
  • Keep the seed with the dataset. Changing a single cell does not change which positions the shuffle picks, but adding or removing rows does, so note the seed and the row count together.
  • Put long shared instructions in the fixed system text once rather than repeating them in every user cell; it keeps the user column clean.
  • Check the largest-line token estimate against the context or example length limit in your provider's documentation.
  • Sort the CSV by conversation id and then by turn order before loading; grouping depends on the order of the file.

Edge cases to watch

Only neighbouring rows with the same id are joined. If turns of one chat are scattered through the file, you get several short conversations instead of one long one.

A conversation takes its system message from its first row, so a different system cell on a later row of the same conversation is ignored.

Rows are skipped, not repaired. An assistant cell that holds only a space counts as empty because cells are trimmed.

Trimming also removes intentional leading spaces or trailing line breaks from a reply. If those matter to your format, this tool is not the right fit.

Some services expect the final message of every example to be from the assistant, others allow more; this tool always ends a line with an assistant message and never writes tool calls, images or weights.

Common errors and how to fix them

"This looks like a binary file, not a text CSV. Choose a CSV file."
The first 8 KB of the file contained a NUL byte, which plain text never has. Export the sheet as CSV from your spreadsheet program, or save the chat export as text, and load that file.
The page says the CSV needs a header row with at least two columns.
The file was read as a single column, usually because it uses semicolons or tabs. Re-save it with commas between fields, and keep the column names on the first line.
No usable rows appear and every row is listed as skipped.
The user or assistant column is pointing at an empty or wrong column. Change the two selectors and check that the cells hold text.
The download button is disabled.
Either no file is loaded or no row has both cells filled. Fix the selectors or the empty cells; the button turns on as soon as one line can be built.

Best practices

  • Deduplicate and proofread the source rows before converting; the tool copies what the sheet says, mistakes included.
  • Remove personal data from cells first. The conversion happens in this tab, but the JSONL file you create will be uploaded somewhere by you.
  • Record the file name, row count and seed of every dataset version you create.
  • Run the provider's own validation, if it offers one, on the downloaded file before starting a paid job.

What the seed controls

The shuffle is a Fisher-Yates pass, which swaps each position with a random earlier one. The random numbers come from a small deterministic generator started from the seed. Give it the same seed and the same list of lines and it returns the same order every time, on any computer, which is why two runs with seed 42 and a 33 percent share produce the same two files.

Choosing a new seed gives a different but equally random split. The seed is part of the recipe, not of the data: it does not appear in the output files, so write it down next to the dataset if you may need to rebuild the split.

Reading the token summary

Say a 200-row sheet gives 200 lines with an average estimate of 120 tokens, a smallest of 18 and a largest of 960. The total is then close to 24,000 tokens. The 960 line is the one to open first: it is often a pasted email thread or a reply that was never trimmed, and it may exceed the per-example limit in your provider's documentation. Fixing that one row changes the maximum without touching the average.

Frequently asked questions

Does the file go to a server?

No. The CSV is read and converted by this tab, and the download is built from data held in memory. The page does not call any AI service and does not write your rows to localStorage, sessionStorage or IndexedDB.

Will every provider accept this format?

Not necessarily. The messages layout follows the common chat format, but required roles, limits and extra fields vary and change over time. Check your provider's current documentation.

Can I include more than one system message?

No. At most one system message is written, at the start of each conversation.

Why is my validation file smaller than the percentage suggests?

The share applies to lines, not rows. If a conversation id column joined rows together, there are fewer lines than rows, and the count is rounded to a whole number.