CSV to Fixed Width Converter
Legacy upload portals, mainframe batch jobs, COBOL importers, and government filing systems often reject CSV and demand fixed-width (column-aligned) text instead: every field occupies a reserved character range on each line, padded with spaces so values line up in a monospace font. This free CSV to fixed-width converter takes a spreadsheet-friendly CSV and rebuilds that positional layout in your browser by padding — or truncating — each column to the widths you specify.
Paste CSV or upload a .csv file, set a width per column to match the receiving system’s data dictionary or copybook, then copy or download the aligned text. Conversion runs entirely client-side — your rows are not uploaded to a server as part of the transform. Use Fixed Width to CSV when you need the opposite direction: turning a positional dump into a spreadsheet.
Below you will find how padding and truncation work, how to match legacy width specs, why monospace inspection matters before upload, Excel and leading-zero pitfalls on the way in, round-trip behavior with Fixed Width to CSV, and a full troubleshooting and FAQ section for real mainframe and portal upload workflows. Treat the preview as your source of truth: if columns do not realign in monospace, the legacy importer will not either.
Key features
- Pads each CSV column to a specified character width with spaces so lines form a true positional layout.
- Supports truncation when values exceed the target width so lines stay a consistent length for legacy importers.
- Works from pasted CSV or uploaded .csv files without requiring a server-side batch job.
- Produces plain column-aligned text suitable for mainframe, COBOL, and government upload portals.
- Runs entirely client-side so spreadsheet content is not sent to a server for the conversion step.
- Pairs with Fixed Width to CSV for analysis and cleanup before regenerating the positional file.
- Shows a preview so you can verify alignment in the browser before copy or download.
About the CSV to fixed-width text format
CSV is a delimited grid: a header row of field names, then one record per line with commas (and quoting rules) separating cells. Fixed-width text has no delimiters between fields — position is the contract. Character columns 1–10 might be NAME, 11–14 AGE, and 15 onward CITY, with spaces filling unused positions so every line shares the same layout.
Conversion means taking each CSV cell, fitting it into its assigned width (pad on the right with spaces when short; truncate when longer than the width), and concatenating slices into one line per row. Headers may be emitted as a space-aligned label row or omitted when the importer expects data-only records — follow the vendor’s layout document.
Widths must come from the receiving system’s specification (copybook, flat-file schema, or portal help text), not from guessing. Auto-detection on the way in with Fixed Width to CSV approximates layout; on the way out, the importer’s documented start positions and lengths are authoritative.
How it works
The converter parses your CSV into a header and data rows. You assign (or confirm) a character width for each column that matches the legacy layout. Each cell is then fitted into that width: shorter values are padded with spaces (typically on the right); longer values are truncated to the width so the next field still starts at the correct position.
Fitted slices are concatenated in column order to form one fixed-width line per CSV row. Optional header emission places space-padded labels above the data when the receiving process expects them; otherwise only data lines are written.
The result is plain text you can copy or download. Open it in a monospace editor and confirm vertical columns match the specification. If a field looks shifted, fix the widths or remove extra CSV columns before converting again — positional formats have no delimiter to “recover” a misaligned field.
Common use cases
- Rebuilding a positional upload file after editing payroll or enrollment data in Excel or Sheets.
- Preparing a government or regulatory fixed-layout submission from a CSV maintained by analysts.
- Generating COBOL- or mainframe-friendly batch text from a modern CSV extract.
- Round-tripping: Fixed Width to CSV for cleanup, then CSV to Fixed Width for the legacy portal.
- Creating sample fixed-width fixtures for integration tests against a positional importer.
- Converting a vendor template filled as CSV into the exact column widths their FTP drop requires.
How to use this tool
- Obtain the official field widths (and whether a header line is required) from the importer’s documentation or copybook.
- Prepare clean CSV: correct headers, text-formatted IDs with leading zeros, no stray blank columns, UTF-8 when the target accepts it.
- Paste or upload the CSV, set each column’s width to the documented length, and convert.
- Inspect the preview (and a downloaded sample) in monospace; verify row length and a few edge rows (long names, empty fields).
- Upload or hand the file to the legacy system; keep the source CSV until acceptance is confirmed.
Example
Input CSV
NAME,AGE,CITY
Alice,30,New York
Bob,25,ChicagoOutput fixed-width text
NAME AGE CITY
Alice 30 New York
Bob 25 ChicagoTips for best results
- Copy widths from the official data dictionary or copybook — do not invent lengths from a single sample row.
- Inspect the output in a monospace font before upload so padding and column starts are visible.
- Decide whether the target wants a header line; many mainframe jobs expect data rows only.
- Keep leading zeros in ID columns as text in the CSV so padding does not hide a truncated numeric rewrite from Excel.
- Spot-check the longest value in each column — truncation there is where data loss shows up first.
- Strip BOM characters and trailing blank CSV columns that would add unintended empty fields.
- Use Fixed Width to CSV first when you only have a sample dump and need to discover approximate widths before documenting them.
- Archive both the CSV and the generated fixed-width file until the upload is accepted.
Common errors and how to fix them
- Columns look shifted or merged when opened in a monospace editor.
- One or more widths do not match the layout contract. Recount characters against the data dictionary, including filler fields you may have omitted from the CSV. Confirm you did not leave an extra blank column that adds an unintended empty slice.
- Long names or addresses are cut off in the output.
- The value exceeded the assigned width and was truncated so later fields stay aligned. Widen that field only if the importer allows it; otherwise shorten the source value or split into the fields the layout defines (for example ADDRESS1 / ADDRESS2).
- Leading zeros disappeared before or after conversion.
- Excel often strips leading zeros when opening CSV. Keep those columns as Text in the sheet, re-export, and convert again. Fixed-width padding preserves whatever characters are present in the CSV cells — it cannot restore zeros already lost upstream.
- The legacy system rejects the file even though columns look aligned.
- Check record length, whether a header is forbidden, line endings (CRLF vs LF), character encoding (UTF-8 vs a legacy code page), and required filler or sign conventions. Alignment alone does not guarantee every byte rule in the spec.
- Empty fields collapse and shift the next column.
- True fixed-width rows must still emit the full width of spaces for empty cells. If your output omits padding for empties, re-convert with widths applied to every column including blanks. Do not hand-trim spaces from the middle of a line.
- I only have a sample fixed-width file and no written widths.
- Convert the sample with Fixed Width to CSV to explore columns, then measure field lengths in a monospace view or against a vendor sample. Document those widths before using this tool for production uploads — inferred lengths are a starting point, not a substitute for the official map when one exists.
Best practices
- Treat the receiving system’s width table as the source of truth; update your converter settings when the vendor revises the layout.
- Always verify output in monospace at the same tab width / font assumptions you will use for support diffs.
- Validate longest-per-column values before bulk runs so truncation is intentional, not a surprise.
- Prefer regenerating from a clean CSV over hand-editing fixed-width text in a proportional font.
- Record encoding, line endings, header policy, and width version next to archived uploads for audits.
- For recurring jobs, automate with the same documented widths once the ad hoc layout is proven — keep this tool for one-offs and layout rehearsal.
- Redact or limit distribution of files that contain payroll, tax, or health fields even though conversion is local.
What CSV to fixed-width conversion actually does
CSV stores fields as delimited cells. Fixed-width stores fields as character ranges. This conversion maps each cell into a reserved width, pads or truncates to fit, and writes lines with no commas between fields — only positions.
You keep the logical columns from the spreadsheet, expressed the way a mainframe print file or portal upload expects them. The tool does not invent a COBOL copybook, packed-decimal encoding, or EBCDIC binary layout; it produces readable positional text from already-decoded CSV.
Success means every data line has fields starting at the same indices, empty fields still occupy their full width, and the total record shape matches what the importer’s parser was written for.
When to convert CSV to fixed-width
Convert when a legacy portal, bank, payroll vendor, or government system only accepts positional uploads; when a batch job’s JCL or control card describes fixed record layouts; or when you edited data as CSV and must return a column-aligned file.
Skip conversion if the consumer already accepts CSV, JSON, or an API — prefer the modern path. Skip if you still lack authoritative widths; guessing from one row risks silent misalignment across an entire batch.
A practical pattern: Fixed Width to CSV for exploration, Online CSV Editor for cleanup, then CSV to Fixed Width with documented lengths for the final drop.
- Good fit: mainframe uploads, COBOL batch inputs, space-padded gov filings, vendor FTP drops.
- Poor fit: systems that already take CSV/TSV, binary VSAM, or EBCDIC packed records without a text stage.
- Better as a script: nightly production loads with a published copybook and CI checks on record length.
Padding, truncation, and field alignment
Padding fills unused positions so the next field always starts at the same character index. Right-padding with spaces is the common default for alphanumeric fields in print-style layouts. Some numeric conventions left-pad with spaces or zeros; follow the spec when it differs.
Truncation enforces the width when a value is too long. Without truncation, a long city name would push AGE or ZIP into the wrong columns for that row only — catastrophic for positional parsers. Prefer fixing source data or using the layout’s overflow fields over silently losing characters when compliance depends on full values.
Internal spaces (New York, compound surnames) stay inside one field; they are not delimiters. Only the assigned width decides where that field ends.
Matching widths to copybooks and data dictionaries
COBOL copybooks and flat-file dictionaries list picture clauses or start/length pairs. Translate those lengths into the width list you apply here. Include filler fields even if your CSV omits them — you may need empty padded columns to keep later fields on the correct offsets.
Government layouts often publish PDF or spreadsheet dictionaries with position and length. Build your CSV column order to match that sequence before converting; reordering columns after padding is harder than sorting the sheet first.
When the dictionary and a vendor sample disagree, trust the dictionary for production and ask the vendor about the sample. Do not split the difference on widths.
Headers: emit, omit, or label-only
Some human-oriented fixed reports include a header line of labels padded like data. Many machine importers reject any non-data row. Read the upload guide before including headers in the output.
If you emit headers, pad labels to the same widths as data columns so the header itself is positional. A comma-separated header line above fixed-width data is usually wrong for legacy jobs.
For debugging, keep a headed version for humans and a data-only version for upload. Do not mix them in the file you submit.
Excel, Sheets, and preparing the CSV
Spreadsheet apps mutate data on open: leading zeros vanish, long IDs become scientific notation, and dates reformat. Import CSV with columns forced to Text when those values matter, or maintain the sheet with apostrophe/text formatting before export.
Remove blank trailing columns, consistent quote issues, and merged cells before export. Fixed-width conversion assumes a rectangular CSV; ghost columns become empty padded fields and shift everything if widths are assigned by position.
Save as UTF-8 CSV when the target allows Unicode. If the mainframe expects a legacy code page, transcode after generating positional text with a dedicated encoding step — do not assume UTF-8 bytes will be accepted.
Empty fields, fillers, and numeric signs
Empty CSV cells should become a run of spaces equal to the field width. That preserves alignment for following columns. Deleting those spaces by hand breaks the contract.
Layouts often include FILLER or unused reserved zones. Represent them as empty CSV columns with the correct widths, or concatenate constant spaces in a preprocessing step if your sheet should not show them to editors.
Signed numerics, implied decimal places, and overpunch conventions are outside simple space-padding. If the importer expects those encodings, apply them in a specialized step; this converter focuses on character-oriented positional text.
Line endings, record length, and file shape
Many legacy systems expect a fixed record length including or excluding the newline. Confirm whether CRLF (Windows) or LF is required. Wrong line endings can make an otherwise correct payload fail validation.
After conversion, check that every data line has the same character count (before newline). Variable lengths usually mean inconsistent widths, missing fillers, or unexpected multiline CSV fields that were not flattened.
Multiline quoted CSV cells do not map cleanly to single-line positional records. Flatten addresses and comments into one line per field before converting.
Round-trip with Fixed Width to CSV
Fixed Width to CSV helps you explore a sample dump and clean data in a spreadsheet. CSV to Fixed Width rebuilds positional text for upload. Together they support edit-in-modern-tools, submit-to-legacy workflows.
Round-trips are not guaranteed bit-identical. Detection approximates boundaries; padding style, truncation, and header policy may differ from the original producer. For compliance-sensitive feeds, compare your output to a golden vendor sample in a monospace diff.
When detection inferred widths that differ from the official dictionary, always prefer the dictionary on the way out.
Mainframe, COBOL, and portal quirks
Mainframe transfers may wrap files with RDW, block headers, or require a specific RECFM. Your desktop fixed-width text is often an intermediate form that a transfer tool or middleware re-wraps — confirm the handoff format with ops.
Carriage-control columns and printer spacing appear in some reports but not in upload layouts. Do not copy report chrome into an inbound positional file unless the spec says so.
Portal validators may check checksum rows, trailer counts, or file naming patterns in addition to field positions. Passing visual alignment is necessary but not always sufficient.
Typical workflows
Analyst edit: receive a fixed dump, convert to CSV, fix rows in Sheets, convert back with documented widths, upload.
Vendor onboarding: build a CSV template matching the dictionary column order, fill data, generate fixed-width for the first certification file.
Test fixtures: maintain small CSV golden sets in git and generate fixed-width artifacts in CI for importer tests.
Incident recovery: regenerate yesterday’s positional file from the archived CSV when a corrupted upload must be resent.
Browser limits, privacy, and sensitive uploads
Parsing and padding run locally. CSV content is not sent to Convert CSV servers for the transform. Site analytics and advertising follow the privacy policy separately.
Very large sheets can slow the tab. Convert a pilot batch first; use offline scripts for millions of rows once widths are proven.
Payroll, tax, health, and case files often contain PII. Control who receives both the CSV and the fixed-width output, and clear downloads on shared machines after the portal accepts the file.
Quality checklist before you upload
Confirm widths match the current dictionary version. Confirm header policy. Spot-check longest values and empty fields in monospace.
Verify record length, line endings, and encoding. Compare against a known-good sample when available. Note the source CSV and generation time for support tickets.
- Widths from the official spec, not a guess.
- Monospace preview shows stable columns.
- Empty fields still occupy full width.
- No unintended truncation on critical fields.
- Encoding and line endings match the portal.
Related tools and next steps
Need to spreadsheet a positional dump first? Use Fixed Width to CSV. Cleaning headers, blanks, and column order is easiest in the Online CSV Editor before you pad for upload.
If the destination can accept delimited files, prefer CSV or the site’s Excel converters and skip positional formatting. Use this guide when position — not commas — is the contract the importer was written for.
Frequently asked questions
How is this different from Fixed Width to CSV?
Fixed Width to CSV slices positional text into spreadsheet columns. CSV to Fixed Width does the reverse: it pads or truncates CSV cells to specified widths so the text is column-aligned again for legacy uploads.
Where should column widths come from?
From the receiving system’s copybook, data dictionary, or portal documentation. Inferred widths from a sample are only a starting point for exploration — production uploads should use official lengths.
What happens if a value is longer than its width?
It is truncated so later fields stay at the correct positions. Check long values in the preview; widen the field only when the importer’s spec allows it, or shorten/split the source data.
Are empty fields omitted from the line?
No. Empty fields should still occupy their full width as spaces. Omitting padding would shift every following column and break positional parsing.
Is my CSV uploaded to a server?
No. Conversion runs in your browser. See the Privacy Policy for site analytics and advertising.
Should the output include a header row?
Only if the importer expects one. Many mainframe and portal jobs want data rows only. When you do emit headers, pad labels to the same widths as the data columns.
Will leading zeros survive?
They survive if they are still present in the CSV cells. Excel often strips them before you convert — format those columns as Text and re-export, then run this tool again.
Can I recreate EBCDIC or packed-decimal files?
No. This tool produces character-oriented fixed-width text. Binary, packed, or EBCDIC encodings need a separate mainframe-aware step after or instead of this conversion.
Why does a monospace editor show misaligned columns?
Widths are wrong, a filler column is missing, truncation/padding was edited by hand, or the viewer is not using a true monospace font. Fix widths and re-convert rather than inserting spaces manually.
Is there a file size limit?
There is no fixed server quota, but very large CSVs can slow the browser. Prove the layout on a sample, then batch or automate for bulk production files.
Do line endings matter?
Yes. Some systems require CRLF and a specific record length. Confirm line-ending and length rules in the upload guide and verify the file after download.
Can I round-trip without losing data?
Not always bit-identically. Detection, padding style, and truncation can change values. Keep golden samples for compliance feeds and prefer official width maps over inferred ones when regenerating uploads.
For more background on data formats and conversion workflows, read our format guides or browse the converter blog for step-by-step walkthroughs linked to each tool.