csvkit.org
CSV (Comma-Separated Values) utilities, in the browser
Say hi →

CSV to Fixed Width

auto or manual widths · alignment · optional truncation · overflow warning

Convert a CSV into fixed-width columns — the format mainframes, banking interfaces, COBOL programs, and old government feeds still require. Widths can be measured from your data or specified exactly, and any value too long for its column is reported rather than silently shifting every field after it.

csv → fixed width
Or drop a .csv file here, or
ready

How to convert CSV to fixed width

  1. Paste the CSV or drop a file.
  2. Leave widths empty to size each column to its longest value, or enter the exact widths your spec requires, e.g. 10,20,8,4.
  3. Set the gap between columns — many specifications require 0, with no separator at all.
  4. Check the status line for overflow, then copy or download.

Overflow is the thing to watch

With manual widths, a value longer than its column has only two possible outcomes: it's cut, or it pushes everything after it out of position and the whole record misparses at the other end. This tool reports the count either way, and truncate makes the cut explicit and safe. Silence would be the dangerous option — a shifted field in a banking feed is a rejected file at best. Auto widths never overflow by definition, since every column is sized to its longest value.

Gap zero, and why alignment is per column

A strict fixed-width spec usually means no separators: every field occupies exactly its byte range, so set the gap to 0 and give exact widths. Numeric fields are right-aligned by default because that's how numbers are read positionally in these formats — though note many legacy specs want zero padding rather than spaces for numbers, which you can produce by padding the values first with Find & replace.

FAQ

How do I read a fixed-width file back?

Fixed width to CSV, which either detects the column boundaries or takes the same widths list.

Should I include the header?

Most machine-read fixed-width feeds must not have one — untick the box. Keep it for a human-readable report, optionally with the underline.

What happens to tabs and newlines inside cells?

They're replaced with a space, since either would destroy the alignment.

Is anything uploaded?

No — it runs in your browser.

Privacy

100% client-side. No upload. See the privacy policy.