Output CSV without quotes using jq

How to get unquoted CSV from jq: why @csv adds quotes, when join or @tsv is safe, and a minimal-quoting filter that keeps commas and quotes intact.

When people ask jq for CSV, they usually reach for the @csv filter and are then surprised to see every string wrapped in double quotes. Whether you can safely drop those quotes depends on your data. This review explains what jq's CSV options actually change, which approach fits which situation, and where removing quotes quietly breaks the output.

A note on evidence: no tested outputs, version details or destination-specific results were supplied for this article. The examples below follow jq's documented behavior for @csv, @tsv, join and the -r flag. Run them against your own jq version and target application before relying on them.

Short answer: is unquoted CSV suitable for your use?

Unquoted output is suitable when you control the data and know that no field contains a comma, a double quote or a line break. In that case, joining fields with a comma gives cleaner, more readable lines that are easy to grep, diff or paste into a simple script. The decisive tradeoff is structural safety: once any value contains a delimiter, unquoted output silently produces rows with the wrong number of columns, and nothing in jq will warn you.

If the data is user-supplied, comes from an external API, or will be loaded by a spreadsheet or database importer, keep the quotes that @csv produces, or use a minimal-quoting filter that adds quotes only where they are required. Plain tab-separated output via @tsv is a good alternative when the consumer accepts tabs.

What each option actually changes

Two separate kinds of quotes are involved, and confusing them is the most common source of trouble. The first is JSON string quoting: by default jq prints its result as a JSON string, so the whole line is wrapped in quotes and inner quotes are backslash-escaped. The -r (raw output) flag removes that layer. The second is CSV field quoting, which @csv adds deliberately and which -r does not remove.

The examples below use this input file, saved as people.json. The second record intentionally contains both a double quote and a comma.

[
  {"name": "Ada", "city": "London", "age": 36},
  {"name": "Lee \"Bo\" Park", "city": "Austin, TX", "age": 29}
]

@csv without -r

Without -r, each CSV line is itself printed as a JSON string, so you get both layers of quoting. This is rarely what anyone wants.

jq '.[] | [.name, .city, .age] | @csv' people.json

"\"Ada\",\"London\",36"
"\"Lee \"\"Bo\"\" Park\",\"Austin, TX\",29"

@csv with -r

With -r, the JSON layer disappears and you get standard CSV. @csv quotes every string, doubles any embedded double quote, and leaves numbers unquoted. This is correct CSV, and the comma inside "Austin, TX" stays inside its field.

jq -r '.[] | [.name, .city, .age] | @csv' people.json

"Ada","London",36
"Lee ""Bo"" Park","Austin, TX",29

join(",") for fully unquoted output

Building the line yourself with join removes CSV quoting entirely. Converting each value with tostring first avoids type errors on numbers in older jq versions and makes the behavior explicit. The first row looks exactly as many people want. The second row now has four fields instead of three, because the comma in the city name is indistinguishable from a separator.

jq -r '.[] | [.name, .city, .age] | map(tostring) | join(",")' people.json

Ada,London,36
Lee "Bo" Park,Austin, TX,29

Be aware that tostring turns a JSON null into the literal text null. If missing values should be empty, substitute them first, for example with map(if . == null then "" else tostring end).

@tsv for unquoted tab-separated output

@tsv never adds quotes. Instead, it separates fields with tabs and escapes tabs, line breaks and backslashes inside values as backslash sequences. Commas and double quotes pass through unchanged and cause no ambiguity, because the delimiter is a tab. The tradeoff is that the consumer must read tab-separated data and, if exact values matter, understand those backslash escapes.

jq -r '.[] | [.name, .city, .age] | @tsv' people.json

Ada	London	36
Lee "Bo" Park	Austin, TX	29

Minimal quoting: quotes only where needed

A middle ground is to quote a field only when it contains a comma, a double quote or a line break, which is what the common CSV convention requires. Clean values stay unquoted and readable, while risky values remain valid. The filter below defines a small helper for that.

jq -r 'def field: tostring | if test("[\",\r\n]") then "\"" + gsub("\""; "\"\"") + "\"" else . end;
  .[] | [.name, .city, .age] | map(field) | join(",")' people.json

Ada,London,36
"Lee ""Bo"" Park","Austin, TX",29

This relies on jq's regular-expression functions test and gsub, which are not available in very old releases. Check your version if the filter fails to compile.

What not to do

Piping @csv output through a command that strips every double quote, such as sed 's/"//g', is a frequent shortcut. It removes the protective quotes around fields that contain commas and also deletes the escaped quotes that were part of the data, so the result is both structurally broken and different in content from the source. If you need unquoted output, generate it deliberately with one of the approaches above.

Comparison of the approaches

Approach | Quotes in output | Safe with commas, quotes, line breaks | Best fit
@csv with -r | Every string field | Yes | Imports into spreadsheets, databases and CSV parsers
join(",") | None | No | Simple, controlled values such as IDs or numeric fields
@tsv with -r | None | Yes, via tab delimiter and backslash escapes | Shell pipelines and tools that accept tab-separated input
Minimal-quoting filter | Only on fields that need them | Yes | Human-readable CSV that must still parse correctly

Will the result stay usable after copying or sharing?

jq's output is ordinary text, so nothing about it changes when copied, pasted or saved to a file: the characters you see are the characters stored. The usability question is entirely about how the receiving program parses those characters.

  • Column alignment: unquoted output from join is only reliable if no value contains the delimiter. A single stray comma shifts every following column in that row.
  • Multi-line values: a line break inside an unquoted field splits one record into two. @csv and the minimal-quoting filter keep it inside quotes; @tsv escapes it as a backslash sequence.
  • Quotes and data types: CSV quotes mark field boundaries, not data types. Many importers apply their own type detection whether or not a field is quoted, so do not count on quotes alone to preserve leading zeros, long numeric IDs or date-like strings. Test with the specific application you plan to use.
  • Tabs versus commas: pasting tab-separated text into some spreadsheet applications splits it into cells, but this depends on the application and its settings. No destination-specific tests were available for this article, so confirm with your own tool.
  • Readability: unquoted lines are easier to scan and diff by eye, which is the main practical benefit. They do not change searchability or editing in any special way, since all approaches produce plain text.

Choosing an approach

Use join(",") only when you can guarantee the values are free of commas, quotes and line breaks, for example numeric IDs or fixed codes you generated yourself. Use @tsv when your downstream tool reads tab-separated data and you want no quotes at all. Use the minimal-quoting filter when people will read the file but a parser must still handle it correctly. Keep plain @csv when the output goes to an importer you do not control; its extra quotes are harmless to a proper CSV parser and are the safest default.