When Base64 in Databases Makes Sense
Use Base64 for binary data in text columns when: your database has poor or no binary type support, you need to include binary data in JSON columns, you're using a text-based export format that can't represent raw bytes, or you need binary data to be easily readable and debuggable.
The Proper Alternative: Binary Column Types
Modern databases provide dedicated binary column types: BYTEA in PostgreSQL, BLOB in MySQL, VARBINARY in SQL Server. These store data in its natural binary form without the 33% Base64 overhead, with better index support, and without requiring encoding/decoding in application code.
Hashes and Checksums
Cryptographic hashes are frequently stored in databases. Both hex and Base64 representations are common: hex (64 chars for SHA-256) is more readable; Base64 (44 chars including padding) is more compact. For indexed hash columns queried for equality, the size difference matters.
Migration Considerations
If you're migrating from text columns storing Base64 to proper binary types, add the new binary column, populate it by decoding the Base64 values, verify correctness, update application code, then remove the old column. Don't try to do this in a single migration on large tables.
Native binary database types are preferable to Base64 text columns for new schemas. Use Base64 storage when text format compatibility, JSON embedding, or debuggability requirements make it the practical choice.