Xerobit

Fixed Width to CSV Converter

Convert fixed width text into comma-separated values by entering the character width of each column. The tool parses every line according to your widths, trims padding spaces and quotes fields that contain commas or double quotes. It runs entirely in your browser, so nothing is uploaded.

Paste your fixed width data here. Each line should follow the same column structure.

Remove leading and trailing spaces from each extracted field.

Ignore lines that are blank or contain only spaces.

CSV Output

John Doe,30,New York
Jane Smith,25,London

How to use the fixed width to csv converter

  1. Paste your fixed width text into the Fixed width text area.
  2. Enter the character width of each column in the Column widths field, separated by commas (for example: 10, 5, 20).
  3. Toggle Trim whitespace if you want leading and trailing spaces removed from each field.
  4. The converted CSV appears instantly below. Copy it or pipe it into another tool like CSV to JSON.

How fixed width parsing works

Fixed width data stores each field in a set number of characters rather than separating them with delimiters. To convert fixed width to csv, the parser slices each line using the column widths you provide.

For example, given the line John Doe 30New York and widths 11, 3, 9, the parser extracts characters 0 through 10 (John Doe ), then 11 through 13 (30N), and finally 14 through 22. If the line is shorter than the total expected width, the missing columns become empty strings. After extraction, optional trimming removes padding spaces, leaving clean field values ready for CSV formatting.

CSV quoting rules applied

The output follows RFC 4180, the standard format for comma-separated values. When converting fixed width text to csv, any field that contains a comma, a double quote or a newline must be enclosed in double quotes. Double quotes inside a field are escaped by doubling them.

For instance, a fixed width field containing Doe, John becomes "Doe, John" in the CSV. A field containing He said "hi" becomes "He said ""hi""". Fields without these special characters are written as-is, keeping the output compact and compatible with spreadsheet software and downstream tools like csv to xml or csv to yaml.

Common fixed width formats

Many legacy systems still export data in fixed width layouts. Here are typical column structures you might encounter when you need to convert fixed width to csv:

FormatExample widthsUse case
COBOL copybook10, 5, 20, 8Mainframe batch exports
Bank statements8, 30, 12, 12Date, description, debit, credit
Census data2, 3, 5, 10State, county, tract, block
Log files19, 15, 50Timestamp, IP address, message

Knowing the exact character count for each field is essential. Even being off by one character shifts every subsequent column, producing garbled results.

Handling short lines and empty rows

Real-world fixed width files often contain inconsistencies. A line might be shorter than the sum of your specified column widths. When this happens, the parser assigns whatever characters remain to the current column and leaves the rest as empty strings. This prevents errors and keeps row alignment intact.

Empty lines are another common occurrence, especially between record groups. By default, the converter skips lines that are completely blank or contain only spaces. If those empty lines represent intentional null records, uncheck the skip option to preserve them as rows of empty CSV fields. Once cleaned, you can pass the result to csv to html table or csv to markdown for presentation.

From fixed width to other formats

Converting fixed width to csv is usually the first step in modernizing legacy data. CSV acts as a universal interchange format. Once your data is in CSV form, you can transform it further depending on your target system.

  • Use csv to jsonl to stream records into databases or log pipelines.
  • Use csv to array to load the data directly into JavaScript or Python structures.
  • Use csv to tsv if your downstream tool expects tab-separated values instead of commas.

Because the conversion happens locally in your browser, you can safely process sensitive financial or personal records without uploading them to a server.

Worked examples

ExampleInputResult
Simple names and agesFixed width text: John Doe 30 New York / Jane Smith 25 London ; Column widths: 11, 3, 9; Trim whitespace from fields: yes; Skip empty lines: yesJohn Doe,30,New York / Jane Smith,25,London
Fields containing commasFixed width text: Doe, John 42 / Smith, Jane38; Column widths: 11, 2; Trim whitespace from fields: yes; Skip empty lines: yes"Doe, John",42 / "Smith, Jane",38
Data with empty linesFixed width text: Alice 100 / Bob 200; Column widths: 11, 3; Trim whitespace from fields: yes; Skip empty lines: yesAlice,100 / Bob,200

FAQ

What exactly is fixed width data?

Fixed width data is a text format where each field occupies a specific number of characters. Instead of using commas or tabs to separate values, the position and length of each substring determine which column it belongs to.

How do I find the correct column widths?

Check the documentation or schema provided by the system that generated the file. If none exists, open the file in a monospaced text editor and count the characters for each visible column manually.

What happens if a line is shorter than the total widths?

The parser reads as many characters as available. Any remaining columns are treated as empty strings, ensuring the CSV row still has the correct number of fields.

Does this tool handle multi-byte Unicode characters?

Yes. Column widths are measured in JavaScript string characters, so Unicode symbols and accented letters are counted correctly based on their code units.

Is my data sent to a server during conversion?

No. The fixed width to csv conversion runs entirely in your browser using JavaScript. Nothing is uploaded or transmitted over the network.

Can I keep the padding spaces in my fields?

Yes. Uncheck the trim option to preserve all leading and trailing spaces exactly as they appear in the original fixed width text.