Prepare CSV data files for Postman
How to prepare a CSV data file for Postman: what conversion from TSV or spreadsheets changes, how quoting and headers work, and when JSON is the better choice.
A CSV data file lets Postman run the same requests repeatedly with different inputs. Each row becomes one iteration, and each column header becomes a variable you can reference in requests and scripts. Most problems come from the conversion step: data copied from a spreadsheet, exported in another dialect, or saved as tab-separated text. This review covers what that conversion changes, where it can quietly alter your data, and when a different format serves you better.
Is a CSV data file the right choice for your Postman run?
For flat test data, CSV is a sound choice. It suits lists of usernames, IDs, query parameters or expected status codes. The main benefit is that you can maintain it in any spreadsheet or text editor, and it is easy to review in version control. The decisive tradeoff is that CSV is flat and untyped. It cannot express nested objects or arrays, and it carries no information about whether a value is a number, a boolean or text.
Postman's Collection Runner and its command-line runner, Newman, also accept JSON data files. Prefer JSON when an iteration needs nested request bodies, arrays, explicit null values or values whose type matters to your assertions. Plain text values typed straight into an environment or collection variable are simpler when you only need one set of inputs. In that case you have nothing to iterate over, so a data file adds no benefit.
| Need | CSV data file | JSON data file |
| One flat set of values per iteration | Well suited | Works, more verbose |
| Nested objects or arrays per iteration | Not supported without encoding values as strings | Supported |
| Value types (number, boolean, null) | No type information in the format | Expressed directly |
| Editing in a spreadsheet | Natural fit | Not practical |
| Reviewing changes line by line | Easy, one row per iteration | Possible, depends on formatting |
What converting to CSV actually changes
Converting tab-separated or spreadsheet data to CSV changes the stored characters in the file. Nothing about it is visual or presentational. Delimiters are replaced, and some fields gain quoting so that commas, quotation marks and line breaks inside a value are not mistaken for structure. The underlying values should stay the same. A good conversion is one where every field reads back exactly as it was entered.
The common CSV rules are these. A field that contains a comma, a double quote or a line break is wrapped in double quotes. A double quote inside such a field is written as two double quotes. The example below assumes the tab-separated source treats quotation marks as literal characters. Some tools apply quoting rules to TSV as well, so check how your source was produced.
Tab-separated input, with tabs between fields:
username password note
alice s3cret first user
bob pa,ss "quoted"
Equivalent CSV output:
username,password,note
alice,s3cret,first user
bob,"pa,ss","""quoted"""
In the second data row, the password pa,ss is quoted because it contains a comma. The note value is the word quoted surrounded by literal quotation marks. Each of those marks is doubled, and the whole field is wrapped in quotes. A converter that simply swaps tabs for commas would have split bob's password into two columns. It would also have left the quotes in a form a CSV parser could interpret differently.
The terms reverse, mirror and font sometimes appear in text-tool collections. None of them applies to this conversion. Reordering columns or rows is a structural edit, not a character reversal. Decorative Unicode letters are different code points from ordinary letters, even when they look similar, so avoid pasting them into test data. An API will receive those code points literally, and they will not match plain-text values on the server.
How Postman reads the file
Postman reads the first row as column headers, and each later row as one iteration. Inside requests, you reference a column as a variable using double curly braces with the header name. In scripts, the current row's values are available through the iteration data object.
POST {{baseUrl}}/login
{
"username": "{{username}}",
"password": "{{password}}"
}
// In a test or pre-request script
const user = pm.iterationData.get("username");
With Newman, the data file is passed with the iteration data option:
newman run collection.json -d data.csv
Header names therefore need to match variable references exactly, including case. Avoid leading or trailing spaces in headers, because a header written as ' username' will not resolve as username. Because the format has no types, don't assume a value like 42 or true arrives as a number or boolean. Write assertions that compare against the form your scripts actually receive, and confirm that in a run before relying on it.
Will the file stay usable after copying, exporting or sharing?
CSV is plain text, so it survives copying and sharing better than most formats. Most of the risk sits at the export and paste steps. Check the following before running a collection.
- Delimiter: copying cells from a spreadsheet usually puts tab-separated text on the clipboard, not comma-separated text. Pasting that into a file named .csv does not make it CSV.
- Regional export settings: some spreadsheet locales export with semicolons instead of commas. Open the saved file in a text editor and confirm the separator.
- Encoding: save as UTF-8. Some editors add a byte order mark at the start of the file, which can attach an invisible character to the first header name. If the first column's variable fails to resolve while others work, check for this.
- Line breaks inside values: these are valid only inside quoted fields. Unquoted line breaks create extra rows and shift every following iteration.
- Trailing blank lines: depending on the tool that produced the file, an empty final line may be read as an extra row. Remove them, or confirm the iteration count in the runner's preview.
- Spreadsheet auto-formatting: values such as long numeric IDs, leading zeros or date-like strings can be reformatted before export. Compare a few exported values with the source.
- Sensitive data: credentials and personal data in a shared data file travel with it. Use dedicated test accounts, or keep secrets in variables that are not committed with the file.
Accessibility concerns are narrow here. A CSV file has no visual styling, and its reading order is the order of its rows and columns. Screen readers and search tools treat it as ordinary text. The practical requirement is that headers be descriptive, so that anyone reviewing the file or the run results can tell what each column controls.
A short preparation checklist
- Decide whether the data is flat. If any iteration needs nested structure or typed values, use JSON instead.
- Write a header row whose names exactly match the variables used in your requests and scripts.
- Convert from TSV or spreadsheet exports with a tool that applies CSV quoting rules, not a plain delimiter swap.
- Save as UTF-8 and inspect the file in a text editor for the separator, stray characters and blank lines.
- Load the file in the Collection Runner and check the preview. Confirm the iteration count matches the number of data rows and spot-check a row with commas or quotes.
Gaps in this review
No specific conversion tool was tested for this article, and no measured results are reported. The behavior described for quoting reflects the common CSV conventions. Postman's handling is described at the level of its general documented workflow. Details such as how a byte order mark or a trailing blank line is treated can vary between Postman versions and export tools. Confirm them with a small sample file in your own setup before running a large data set.