Convert Binary Data to CSV

What converting binary data to CSV actually changes, when it preserves meaning, and where encoding, byte layout and spreadsheet handling can break the result.

Searches for a binary to CSV converter cover several different jobs that share one label. Some people have a string of 0s and 1s they want to read as text. Others have a binary file produced by a device, program or database and want its records in rows and columns. A third group needs to store raw bytes inside a CSV cell. A converter is only suitable if it handles the job you actually have, so it helps to identify that first.

What "binary" can mean here

  • A bit string written as text, such as "01001000 01101001", where each group of eight digits stands for one byte.
  • A structured binary file, where records are stored as fixed or variable byte layouts (integers, floating-point numbers, timestamps, strings) rather than as readable characters.
  • Opaque binary content, such as an image or a compressed blob, that has no tabular structure and can only be placed in a CSV field as an encoded string.

What the conversion actually changes

CSV is plain text: rows are separated by line breaks and fields by a delimiter, usually a comma. Bytes on their own have no rows, columns or types. To turn them into CSV, a converter has to apply an interpretation: how many bytes make one record, what type each field is, which byte order is used, and which character encoding applies to any text. The output is a new file made of different characters, not a different view of the same data. This is a stored change, unlike a hex editor that only displays bytes differently while leaving the file untouched.

Because CSV has no built-in types, information that the binary format carried implicitly, such as "this field is a 16-bit signed integer" or "these four bytes are a 32-bit float", is lost unless you record it separately, for example in a header row or accompanying documentation. Converting back from CSV to the original binary layout requires that information.

Checking examples against the mechanism

For a bit string, the conversion splits the digits into 8-bit groups and maps each byte to a character using an encoding. In the example below, 01001000 is hexadecimal 48, the ASCII and UTF-8 code for "H", and 01101001 is hexadecimal 69, the code for "i".

input:   01001000 01101001
bytes:   0x48     0x69
output:  H        i

This only works if the digit count is a multiple of eight and the right encoding is assumed. Characters outside the ASCII range use more than one byte in UTF-8, so splitting the bytes per CSV field without regard to character boundaries can produce broken characters.

For structured files, byte order changes the value. The same four bytes produce very different numbers depending on whether the converter reads them as little-endian or big-endian:

Bytes (hex) | Read as | Value
01 00 00 00 | unsigned 32-bit, little-endian | 1
01 00 00 00 | unsigned 32-bit, big-endian | 16777216
48 69 | two ASCII characters | Hi
48 69 | unsigned 16-bit, big-endian | 18537

A converter that guesses the layout can produce a well-formed CSV full of wrong numbers. The file opening cleanly is not evidence that the interpretation was correct; spot-check a few records against known values from the source system.

Floating-point fields add another subtlety. A 32-bit float cannot represent most decimal fractions exactly, so writing it as text can show a value like 0.10000000149011612 where the source program displayed 0.1. Rounding the output for readability is a deliberate loss of precision; keeping full digits preserves the value but looks noisier.

A minimal local example for fixed-length records

When the record layout is known, a short script makes every assumption explicit. This Python sketch reads 10-byte records made of an unsigned 32-bit integer, a signed 16-bit integer and a 32-bit float, all little-endian with no padding. The layout and field names are placeholders; they must match your actual format.

import csv
import struct

record = struct.Struct("<Ihf")  # uint32, int16, float32, little-endian, no padding

with open("data.bin", "rb") as src, open("data.csv", "w", newline="", encoding="utf-8") as dst:
    writer = csv.writer(dst)
    writer.writerow(["id", "offset", "reading"])
    for fields in record.iter_unpack(src.read()):
        writer.writerow(fields)

If the file length is not an exact multiple of the record size, the unpacking step raises an error rather than silently misreading data, which is a useful signal that the layout is wrong or the file has a header. Files with headers, variable-length records or nested structures need format-specific parsing rather than a single fixed layout.

Placing raw bytes inside a CSV field

Opaque binary content cannot be put into CSV directly, because arbitrary bytes may include delimiters, line breaks or sequences that are invalid in the file's text encoding. The usual approach is to encode the bytes as hexadecimal, which doubles the size, or Base64, which grows it by roughly one third. Either keeps the data intact and reversible, but the field becomes unreadable to people and is meaningful only to software that decodes it.

Will the result stay readable and usable after sharing?

Encoding: a CSV saved as UTF-8 may be misread by software that assumes a different encoding, turning accented or non-Latin text into garbled characters. Some workflows add a byte order mark to signal UTF-8, while some parsers treat that mark as part of the first header name. State the encoding when sharing the file.

Delimiters and quoting: the conventions described in RFC 4180 enclose fields containing commas, double quotes or line breaks in double quotes and double any embedded quotes. Not every tool follows these conventions, and in regions where the comma is the decimal separator, semicolons are often used as the field delimiter instead. A file that parses correctly in one tool can split columns incorrectly in another.

Spreadsheet reinterpretation: spreadsheet programs commonly guess types when opening CSV files. Leading zeros in identifiers can be dropped, long integers can be shown in scientific notation or lose trailing digits, and strings that resemble dates can be converted. Hex strings consisting only of digits are especially exposed. Importing with columns explicitly set to text, or validating with a CSV-aware tool instead of a spreadsheet, avoids silent changes. Behavior varies by program and settings, so test with the destination you actually use.

Copy and paste: long bit strings and encoded fields are easy to damage when copied through chat apps, documents or email, which may wrap lines, insert spaces or trim characters. One missing digit shifts every following byte. Transferring the file itself is more reliable than pasting its contents.

Accessibility, search and editing: decoded values in labeled columns are generally easier to search, filter and navigate with assistive technology than raw binary, especially when opened in a table-aware viewer. Raw bit strings, hex and Base64 offer no meaningful content to a screen reader or a search query. If people need to read the data, provide decoded, labeled columns; if exact bytes must be preserved, keep the encoded field alongside a readable equivalent rather than in place of it.

Privacy when using online converters

A browser-based converter's appearance or wording does not tell you whether data is uploaded, logged or retained. Binary exports from devices and databases often contain personal or operational data. Unless a tool's documented processing model is clear and acceptable, converting sensitive files locally with a script or offline tool is the safer default.

Is converting to CSV suitable for your use?

Converting binary data to CSV is a good fit when the data is genuinely tabular, the byte layout is documented, and the goal is inspection, analysis or import into tools that read delimited text. The main benefit is that values become readable and portable across a wide range of software. The decisive tradeoff is that CSV discards type and layout information and invites reinterpretation by the software that opens it, so correctness depends on knowing the source format and controlling how the file is read.

  • CSV is a reasonable choice when records have a known, consistent structure and the output will be read by people or analysis tools.
  • Keep the original binary, or share plain hex or Base64 text, when exact bytes must be preserved or the data has no row-and-column structure.
  • Use a plain-text decode instead of CSV when you only need to read a bit string as characters; a delimited format adds nothing there.
  • Keep a format-native export when the source program offers one, since it is less likely to misread the layout than a generic converter.

Gaps in this review

No specific converter, service or spreadsheet program was tested for this article, and no measurements of accuracy, speed or file-size limits are reported. The statements above describe general mechanisms and widely documented conventions. Behavior of any named tool, its handling of encodings and edge cases, and its data retention practices should be confirmed from that tool's own documentation or a scoped test with representative files.