CSV to Barcode
Operator: Abdulla Al Fahad. How tools are built and checked
CSV to Barcode makes one barcode for every value in a column of your CSV. If you keep a product list, a stock sheet or an asset register in a spreadsheet, you can pick the column that holds the SKUs or EAN numbers and download a ZIP with one SVG barcode per row, ready to place on labels.
Code 128 here uses Code Set B, which covers printable ASCII from code 32 (space) to code 126 (~), so a SKU with an accented letter or a pasted en dash is rejected with the character named. One run makes up to 2,000 barcodes.
Two symbologies are supported: Code 128, which handles letters, digits and punctuation and is the usual choice for internal SKUs and asset tags, and EAN-13, the 13-digit retail code used worldwide; North American UPC-A numbers are the same code with a leading 0.
Key features
- Code 128 (Code Set B) for any printable ASCII text up to 80 characters.
- EAN-13 from 12 digits, with the check digit calculated for you, or from 13 digits, with the check digit verified.
- One SVG file per valid row, packed into a single ZIP download.
- File names taken from the encoded value, with unsafe characters replaced and duplicates numbered _2, _3 and so on.
- Adjustable module width (1 to 6 px) and bar height (20 to 300 px), with the value printed under the bars or left off.
- A summary of valid rows, invalid rows with their row number and reason, and empty rows skipped.
- Live preview of the first six barcodes before you download.
What changes between CSV and ZIP of SVG barcodes
The input is a CSV with a header row. Only the column you choose is used; other columns, such as product names or prices, are ignored. Each value is trimmed of surrounding spaces before it is encoded, and rows where the chosen cell is empty are counted and skipped.
Each barcode is a standalone SVG: black bars on a white background with the quiet zones (blank margins) that scanners need on both sides. Code 128 gets ten modules of margin on each side. EAN-13 gets eleven on the left and seven on the right, with the guard bars extended below the digits in the usual retail layout.
The module width is the width of the thinnest bar in pixels. At the default of 2 px, the Code 128 barcode for TS-BLK-M-0412 is 396 px wide and an EAN-13 is 226 px wide. Because the files are vector, you can scale them in a label editor, but keep the scaling uniform so the bar ratios stay intact.
The ZIP contains only the SVG files, named after the encoded value, for example TS-BLK-M-0412.svg or 5012345670058.svg. Characters that are not allowed in file names on common systems (/ \ : * ? " < > | and control characters) become underscores.
How it works
For Code 128, every character must be printable ASCII, from space (32) to tilde (126). The encoder starts with the Code Set B start symbol (value 104), then adds one symbol per character whose value is the character code minus 32. The check symbol is 104 plus the sum of each symbol value multiplied by its position, starting at 1, taken modulo 103. The stop pattern, including its final termination bar, closes the barcode. Each symbol is drawn from the standard ISO/IEC 15417 width table.
For TS-BLK-M-0412 that gives 13 data symbols, a check value of 31, and 178 modules in total between the quiet zones. As a check on the method, the word Hello produces the check value 76.
For EAN-13, the value must be digits only. With 12 digits, the check digit is calculated: add the digits in positions 1, 3, 5, 7, 9 and 11, add three times the digits in positions 2, 4, 6, 8, 10 and 12, and the check digit is whatever brings that total up to the next multiple of ten. With 13 digits, the same calculation must match the last digit, or the row is rejected. The first digit then selects the left-half parity pattern, and the bars are built from the standard L, G and R digit codes.
Validation happens per row. A failure in one row never stops the others, and the summary lists up to 25 failures with the spreadsheet row number (row 1 is the header) so you can fix them in the source file.
Common use cases
- An online shop printing Code 128 labels for its own SKUs, such as TS-BLK-M-0412, from the product sheet it already keeps.
- A small brand with an assigned GS1 company prefix generating EAN-13 barcodes for a new range from a list of 12-digit item numbers.
- An office manager tagging laptops and monitors with asset numbers from an inventory CSV.
- A warehouse labelling shelf locations like A-03-2 so pickers can scan them with a handheld reader.
- A school library printing barcodes for newly catalogued books from an exported list of accession numbers.
How to use this tool
- Paste your CSV or upload a .csv file. The sample shows a short SKU list with an EAN column you can experiment with.
- Choose the column that holds the values to encode.
- Pick Code 128 for mixed letters and digits, or EAN-13 for 12- or 13-digit retail numbers.
- Adjust the module width and bar height to suit your labels, and decide whether to print the value under the bars.
- Read the summary. Fix any invalid rows in the source file if they matter, then download the ZIP.
Example
CSV input (sku column, Code 128; the ean column, EAN-13)
sku,product,ean
TS-BLK-M-0412,"T-shirt, black, M",5012345670010
TS-BLK-L-0413,"T-shirt, black, L",5012345670027
MUG-350-WHT,Mug 350 ml white,5012345670034
CAP-NVY-OS,"Cap, navy, one size",5012345670041
BAG-CNV-01,Canvas tote bag,5012345670058
NB-A5-DOT,A5 dotted notebook,5012345670059Result
sku column, Code 128: 6 valid, 0 invalid
TS-BLK-M-0412.svg TS-BLK-L-0413.svg MUG-350-WHT.svg
CAP-NVY-OS.svg BAG-CNV-01.svg NB-A5-DOT.svg
ean column, EAN-13: 5 valid, 1 invalid
Row 7 (5012345670059): check digit is 9 but the
first 12 digits give 8; check for a typoTips for best results
- Format barcode columns as text in your spreadsheet before exporting. Otherwise long numbers can turn into 5.01235E+12 or lose leading zeros.
- To encode a 12-digit UPC-A number as EAN-13, add a 0 in front so it has 13 digits. If you enter the 12 digits alone, they are treated as the start of an EAN-13 and a different 13th digit is added.
- Keep the value printed under the bars. If a label gets scuffed, staff can still type the code by hand.
- Test-print one label and scan it with the reader you will actually use before printing a full sheet.
- Use a module width of 2 px or more if the SVGs will be placed at their original size; thinner bars are harder for basic scanners to resolve.
Edge cases to watch
Generating an EAN-13 barcode does not register the number. Retail EAN numbers must come from a GS1 company prefix assigned to your business; making up numbers can clash with real products in a retailer's system.
Code 128 here uses Code Set B only. Long all-digit values work but produce a wider barcode than a scanner-optimised Code Set C encoding would.
Characters outside printable ASCII, such as é, ü or an en dash pasted from a word processor, are rejected for Code 128. The summary names the character and its position.
Spreadsheet scientific notation (for example 5.01235E+12) is caught for EAN-13 and reported, but the original digits are lost, so the fix has to happen in the source spreadsheet.
Common errors and how to fix them
- "check digit is 9 but the first 12 digits give 8"
- The 13-digit value has a typo or was truncated. Compare it with the number on the packaging or in your GS1 records. If you only have the first 12 digits, enter those and the tool will add the correct check digit.
- "EAN-13 needs 12 or 13 digits, this value has 11"
- A leading zero was probably dropped by a spreadsheet. Format the column as text, restore the zero and export again.
- "character 4 is "é", which Code 128 Set B cannot encode"
- Replace accented letters and typographic punctuation with plain ASCII in the source column, for example e for é and a normal hyphen for an en dash.
- "over the 80-character limit for Code 128"
- Barcodes that long are too wide for most labels and hard to scan. Use a shorter identifier, such as an SKU or ID, and keep the long text in your system.
- Some rows were "not processed because a run stops at 2,000 barcodes"
- Split the CSV into files of 2,000 rows or fewer and run each one separately.
Best practices
- Use Code 128 for internal identifiers and EAN-13 only for numbers issued under your GS1 company prefix.
- Keep identifiers short and avoid characters that look alike, such as O and 0 or I and 1, if people may need to type them.
- Leave the white margins around each SVG intact when placing it on a label; cropping the quiet zone is a common reason for failed scans.
- Print black bars on a white or very light background. Coloured or low-contrast labels scan poorly.
- Keep the CSV as the source of truth and regenerate barcodes from it, rather than editing the SVG files by hand.
What this version does not do
The tool focuses on producing correct barcode files from a column of values. It does not lay out label sheets, add product names or prices beside the bars, or print directly. Place the SVGs into your label software, word processor or design tool for that step.
- No EAN-8, UPC-A, UPC-E, ITF-14, Code 39 or QR codes in this version (there is a separate CSV to QR Code tool for QR).
- No GS1-128 application identifiers or FNC1 characters.
- No custom fonts or colours; bars are black on white and the text uses a monospace system font.
- No PNG or PDF output; the ZIP contains SVG files only.
Limits and file naming
A single run creates up to 2,000 barcodes. Code 128 values are limited to 80 characters, and EAN-13 values must have 12 or 13 digits; spaces and hyphens inside an EAN are ignored, so 501 2345 67001 0 is read as 5012345670010.
Each file is named after the value it encodes, with unsafe characters replaced by underscores. Two values that produce the same file name, such as SKU/1 and SKU:1, are saved as SKU_1.svg and SKU_1_2.svg, so nothing is overwritten inside the ZIP. Names are compared without regard to case, which avoids clashes when the ZIP is opened on Windows or macOS.
Frequently asked questions
Are the barcodes created on a server?
No. The page reads your CSV with the browser's file API, calculates the bar pattern for each value and writes each SVG as text in the tab, then packs them with a ZIP library that runs in the page.
Will these barcodes scan in shops?
The bar patterns follow the Code 128 and EAN-13 specifications, so standard scanners can read them when printed clearly. Whether a shop's till recognises an EAN-13 depends on the number being registered to your business through GS1, which this tool cannot do for you.
Can I make a barcode from a 12-digit UPC?
UPC-A output is not available in this version. You can add a leading 0 to the 12-digit UPC and generate it as EAN-13, which most retail scanners read as the same product.
What size should I print them?
That depends on your scanner and label. Check the specification of your scanner or label printer for the narrowest bar it can read or print, and scale the SVG uniformly, never in one direction only. GS1 publishes minimum sizes for each symbol if the barcodes will be scanned at a retail till.
Why are some rows marked invalid?
Each invalid row lists its reason: a wrong EAN-13 check digit, the wrong number of digits, a character Code 128 Set B cannot encode, or a value over 80 characters. Up to 25 are listed with row numbers; fix them in the CSV and paste it again.
Can I change the bar colour?
No. Bars are always black on white, which gives scanners the highest contrast. You can recolour the SVG in a vector editor, but test the result with your scanner afterwards.