PostgreSQL Bytea Converter (Hex, Escape, Base64, Text)
Paste a bytea value the way psql shows it (\x48656c6c6f), an escape-format string, base64, plain hex or ordinary text, and get every other representation back: the hex literal to insert, the bytea_output = 'escape' form, base64 as encode() prints it, a hex dump, and the UTF-8 text if the bytes are valid UTF-8. Parsing follows the same rules and error messages as PostgreSQL's bytea input, decode() and convert_from(), so you can see why a value is rejected before you run the query. Everything runs in your browser.
Do more than postgresql bytea converter (hex, escape, base64, text) — meet Chat2DB
Chat2DB is an AI-powered SQL client for Windows, macOS and Linux. Write SQL in natural language, format and optimize queries automatically, and manage MySQL, PostgreSQL, Oracle and 20+ other databases in one workspace.
How to use
- Choose the input format (Postgres \x hex, escape format, plain hex, base64 or text) and paste the value; full SQL literals like '\x..'::bytea are unwrapped automatically.
- Click Convert to see the byte length, the hex and escape forms, base64, a hex dump and the decoded UTF-8 text.
- Copy the generated INSERT, decode() or convert_from() SQL and adjust the table and column names for your schema.
Frequently asked questions
How do I convert a Postgres bytea column to a readable string?
If the bytes are UTF-8 text, use convert_from(col, 'UTF8'). If they are binary, use encode(col, 'hex') or encode(col, 'base64') to get a printable string. A plain col::text cast does not decode the bytes; it returns the \x hex representation as text.
What is the difference between bytea hex and escape format?
Hex format writes every byte as two hex digits after a \x prefix and has been the default bytea_output since PostgreSQL 9.0. Escape format keeps printable ASCII as-is and writes other bytes as backslash plus three octal digits, with a backslash itself written as \\. Postgres accepts both on input; bytea_output only controls how values are printed.
Is there an easier way to inspect binary columns?
Chat2DB connects to PostgreSQL and shows query results in a grid, and its AI assistant can write the encode(), decode() and convert_from() calls for you. Download it from chat2db.ai/download or use the web version at app.chat2db.ai.
