JSON, CSV, and Base64: picking the right format for the job

These three formats solve different problems -- structure, tabular simplicity, and safe transport -- and picking the wrong one is a common source of avoidable headaches.

JSON, CSV, and Base64 get used interchangeably by people who just need 'to get data from one place to another,' but they solve genuinely different problems, and picking the wrong one causes specific, predictable headaches later.

JSON: nested structure, at a size cost

JSON represents nested, hierarchical data naturally -- objects inside objects, arrays of varying length, optional fields. That flexibility comes at a size and readability cost for large flat datasets: representing a spreadsheet-shaped table in JSON repeats every field name on every row, which CSV avoids entirely.

CSV: efficient for flat tables, fragile for anything else

CSV is compact and universally supported by spreadsheet tools, which makes it the right choice for genuinely flat, tabular data. It has no standard way to represent nested structure, and it's notoriously fragile around commas, quotes, and line breaks inside a field's own text -- a comma inside an unquoted text value is one of the most common real-world CSV parsing bugs.

Base64: not a data format at all

Base64 doesn't organize data the way JSON or CSV do -- it's an encoding scheme that represents arbitrary binary data (an image, a file) as plain text characters, so it can be safely embedded somewhere that only accepts text, like inside a JSON string or a URL. Base64-encoded data is roughly 33% larger than the original binary, which is the trade-off for making it text-safe. Using Base64 to encode data that's already plain text (like using it as a 'format' for a config file) is a common misuse -- it adds size and an extra decode step for no real benefit.