CSV to C Array Converter

Convert a spreadsheet or CSV column into a C array, or turn a whole CSV into an array of structs, for calibration tables and lookup tables in firmware.

CSV to C array

Conversion runs locally in your browser. No data is uploaded to the server.

Input and options

Paste or load a CSV file to generate a C array.

C output

Rows-
Estimated size-

Turning a spreadsheet into a firmware lookup table

Calibration curves, ADC-to-temperature tables, gamma tables, and sine tables are often built and checked in a spreadsheet first. This tool takes that CSV export and turns one column into a flat C array, ready to declare as const data in firmware without retyping values by hand.

Single column vs array of structs

Single column mode picks one column and generates a flat array such as const uint16_t lookup_table[]. Array of structs mode uses every column, generating a typedef struct with one field per column and one initializer per CSV row, which keeps related values like an ADC code and its calibrated temperature together in a single entry.

Choosing a data type and number format

Pick the C type that matches your target: uint16_t is common for raw ADC codes, float or double for calibrated physical values, and 8/16/32-bit signed or unsigned integers for packed protocol data. Hex output is useful for register values or bit masks, while decimal is easier to read for calibration data.

FAQ

Can I convert just one column of a multi-column CSV?

Yes. Choose Single column mode and pick the column from the dropdown, which is populated from your header row or generated column names.

What is array of structs mode for?

It converts every column into one C struct with a field per column, and every CSV row into one struct initializer, which is useful for lookup tables that pair a raw value with a calibrated value.

Does this support negative numbers in hex format?

Yes. Negative values are encoded using two's complement for the selected bit width, matching how signed integer types are represented in memory.

What happens if a CSV cell is not a number?

The tool treats it as 0 and shows a warning with the count of invalid values, so you can go back and fix the source data.

Is my CSV data uploaded to a server?

No. Parsing and code generation run locally in your browser JavaScript, and no data leaves your device.

Related tools