1001Ferramentas
📐 Converters

Fixed-Width ↔ CSV/JSON Converter

Converts fixed-width text files to CSV, TSV or JSON and back, with automatic column detection, a position map and per-line warnings.

Widths mode: name:14,state:2 — one width per column, in order. Positions mode: name:1-14,state:15-16 — 1-indexed and inclusive on both ends.

How the two specification modes differ

Widths mode adds up as it goes: name:14,state:2,amount:10 means characters 1 to 14, then 15 to 16, then 17 to 26. Positions mode names the start and the end of each field, so you can skip filler columns and read only what matters — useful when the layout document lists 60 fields and you need four of them.

Automatic detection looks for character columns that are blank on every single line and treats runs of two or more as separators. It fails on layouts where a value touches the next field, and it will merge two columns whose gap is a single space. When that happens, take the generated position map, fix the boundary by hand and convert again.

Convert fixed-width files to CSV and back

A fixed-width file has no separator: every field takes an exact number of characters and the leftover space is padded with blanks or zeros. Bank return files, mainframe extracts and the TXT many ERPs produce instead of a CSV all look like that, and a spreadsheet opens them as a single column. Describe the layout once, as name:14,state:2,amount:10, and get CSV, TSV or JSON out.

Widths mode adds fields up in order: 14 characters for the name, 2 for the state, 10 for the amount. Positions mode names the start and end of each field, so you can skip filler and read four fields out of a sixty-field layout. Automatic detection looks for character columns that are blank on every line and treats runs of two or more as separators, which is why it merges two fields parted by a single space.

Going the other way, the CSV becomes positional again: each field is padded to the declared width, with trailing spaces or leading zeros, the way numeric fields are usually written in transmission files. A value that does not fit is cut off, and the tool reports the line, the field and the original length. Finding that here beats finding it in the rejection report a day later.

Frequently asked questions

What happens when a line is shorter than the layout?
It does not stop the conversion. Fields that run past the end of the line come out empty and a warning tells you how many characters the line has and how many the specification needs. That usually means a trailer line or a different record type mixed into the file.
Does automatic detection work on every file?
No. It needs at least two blank character columns between fields on every line. Layouts where a long value touches the next field defeat the inference. When that happens, take the generated position map as a starting point and fix the boundary by hand before converting again.
Is my data uploaded anywhere?
No. Everything runs in your browser in JavaScript, and nothing you paste leaves the machine. You can go offline, reload the page from cache and the conversion still works, which matters when the file is a payroll or bank extract.

Related Tools