Converting Hex to ASCII With xxd
Hex-encoded strings are common in system administration, debugging, and network packet analysis. Whether you’re examining binary data, decoding network protocols, or troubleshooting data encoding issues, you’ll often need to convert between hex and ASCII representations.
xxd is the standard tool for this task on Unix-like systems. It creates hexdumps and reverses them back to binary form — which for ASCII means converting back to readable text.
How xxd Works
xxd reads binary or text input and outputs a three-column format by default:
$ echo "abcdefghijklmnopqrstuvwxyz" | xxd
00000000: 6162 6364 6566 6768 696a 6b6c 6d6e 6f70 abcdefghijklmnop
00000010: 7172 7374 7576 7778 797a 0a qrstuvwxyz.
The hex string for “abcdefghijklmnopqrstuvwxyz” is 6162636465666768696a6b6c6d6e6f707172737475767778797a0a.
Key xxd Options
For hex-to-ASCII conversion, these options matter:
| Option | Purpose |
|---|---|
-p or -plain |
Output plain hex dump without line numbers or column layout |
-r or -revert |
Reverse mode: convert hex back to binary |
-u |
Use uppercase hex letters (doesn’t affect conversion result) |
Converting Hex to ASCII
Combine -r (revert) with -p (plain) to convert hex dumps without worrying about formatting:
$ echo "6162636465666768696a6b6c6d6e6f707172737475767778797a0a" | xxd -p -r
abcdefghijklmnopqrstuvwxyz
This works equally well with uppercase hex:
$ echo "6162636465666768696A6B6C6D6E6F707172737475767778797A0A" | xxd -p -r
abcdefghijklmnopqrstuvwxyz
Case doesn’t matter for the hex input — xxd -r handles both automatically.
Practical Examples
Converting from a file containing hex:
$ xxd -r -p < hexdump.txt > output.bin
Handling hex with whitespace and newlines:
The -r -p combination ignores extra whitespace, so you can paste formatted hex from documentation:
$ cat << 'EOF' | xxd -r -p
48656c6c 6f0a
57 6f 72 6c 64
EOF
Hello
World
Verifying conversions by round-tripping:
$ echo "Hello, World!" | xxd -p
48656c6c6f2c20576f726c6421 0a
$ echo "48656c6c6f2c20576f726c6421 0a" | xxd -r -p
Hello, World!
Converting hex with control characters and binary data:
Not all hex represents text. If your data contains null bytes or non-printable characters, xxd -r -p handles them correctly — you just won’t see them in terminal output:
$ echo "4865 6c00 6c6f" | xxd -r -p | od -c
0000000 H e l \0 l o
0000006
Common Edge Cases
Incomplete bytes: xxd requires pairs of hex digits. An odd number of characters will fail:
$ echo "4865 6c" | xxd -r -p
xxd: incomplete input
Line length and formatting: For very long hex strings, -p ensures xxd doesn’t insert line breaks that would break the conversion:
# Without -p, long input may be split across lines
$ xxd -r file.hex # May fail with malformed input
# With -p, whitespace is ignored
$ xxd -r -p file.hex # Works correctly
Alternatives
For simple one-liners, printf with bash parameter expansion works for small inputs:
printf '\x48\x65\x6c\x6c\x6f\n'
Hello
For larger data or programmatic use, stick with xxd. For complex binary manipulation, consider od, hexdump, or scripting in Python with bytes.fromhex().
The xxd -r -p combination remains the fastest and most portable way to convert hex strings to ASCII on the command line.
2026 Comprehensive Guide: Best Practices
This extended guide covers Converting Hex to ASCII With xxd with advanced techniques and troubleshooting tips for 2026. Following modern best practices ensures reliable, maintainable, and secure systems.
Advanced Implementation Strategies
For complex deployments, consider these approaches: Infrastructure as Code for reproducible environments, container-based isolation for dependency management, and CI/CD pipelines for automated testing and deployment. Always document your custom configurations and maintain separate development, staging, and production environments.
Security and Hardening
Security is foundational to all system administration. Implement layered defense: network segmentation, host-based firewalls, intrusion detection, and regular security audits. Use SSH key-based authentication instead of passwords. Encrypt sensitive data at rest and in transit. Follow the principle of least privilege for access controls.
Performance Optimization
- Monitor resources continuously with tools like top, htop, iotop
- Profile application performance before and after optimizations
- Use caching strategically: application caches, database query caching, CDN for static assets
- Optimize database queries with proper indexing and query analysis
- Implement connection pooling for network services
Troubleshooting Methodology
Follow a systematic approach to debugging: reproduce the issue, isolate variables, check logs, test fixes. Keep detailed logs and document solutions found. For intermittent issues, add monitoring and alerting. Use verbose modes and debug flags when needed.
Related Tools and Utilities
These tools complement the techniques covered in this article:
- System monitoring: htop, vmstat, iostat, dstat for resource tracking
- Network analysis: tcpdump, wireshark, netstat, ss for connectivity debugging
- Log management: journalctl, tail, less for log analysis
- File operations: find, locate, fd, tree for efficient searching
- Package management: dnf, apt, rpm, zypper for package operations
Integration with Modern Workflows
Modern operations emphasize automation, observability, and version control. Use orchestration tools like Ansible, Terraform, or Kubernetes for infrastructure. Implement centralized logging and metrics. Maintain comprehensive documentation for all systems and processes.
Quick Reference Summary
This comprehensive guide provides extended knowledge for Converting Hex to ASCII With xxd. For specialized requirements, refer to official documentation. Practice in test environments before production deployment. Keep backups of critical configurations and data.

how do I convert this data to string dumps
“871EA455E4F2618CBFBB6A607ED88F4B848265D4BB357B0275784ABB2A1584084DBE8C71753FFCBDCADBD9321A2E55422C58B8C6CA398D013D01716B87B0050BF1DD52AF8D657F769621457D8EEFE262FCD32E6F23C192767BEA6DF33841F9BE25F4C9427DA3B7B4F2E937B196425A5F197C25F7D0C545FBFCD32E6F23C192767BEA6DF33841F9BE290CB5D22715F507
frankzhou@XA014D:~/github/gsm-pdu-decoder$ echo -n 871EA455E4F2618CBFBB6A607ED88F4B848265D4BB357B0275784ABB2A1584084DBE8C71753FFCBDCADBD9321A2E55422C58B8C6CA398D013D01716B87B0050BF1DD52AF8D657F769621457D8EEFE262FCD32E6F23C192767BEA6DF33841F9BE25F4C9427DA3B7B4F2E937B196425A5F197C25F7D0C545FBFCD32E6F23C192767BEA6DF33841F9BE290CB5D22715F507 | xxd -r -pi | xxd -i
0x87, 0x1e, 0xa4, 0x55, 0xe4, 0xf2, 0x61, 0x8c, 0xbf, 0xbb, 0x6a, 0x60,
0x7e, 0xd8, 0x8f, 0x4b, 0x84, 0x82, 0x65, 0xd4, 0xbb, 0x35, 0x7b, 0x02,
0x75, 0x78, 0x4a, 0xbb, 0x2a, 0x15, 0x84, 0x08, 0x4d, 0xbe, 0x8c, 0x71,
0x75, 0x3f, 0xfc, 0xbd, 0xca, 0xdb, 0xd9, 0x32, 0x1a, 0x2e, 0x55, 0x42,
0x2c, 0x58, 0xb8, 0xc6, 0xca, 0x39, 0x8d, 0x01, 0x3d, 0x01, 0x71, 0x6b,
0x87, 0xb0, 0x05, 0x0b, 0xf1, 0xdd, 0x52, 0xaf, 0x8d, 0x65, 0x7f, 0x76,
0x96, 0x21, 0x45, 0x7d, 0x8e, 0xef, 0xe2, 0x62, 0xfc, 0xd3, 0x2e, 0x6f,
0x23, 0xc1, 0x92, 0x76, 0x7b, 0xea, 0x6d, 0xf3, 0x38, 0x41, 0xf9, 0xbe,
0x25, 0xf4, 0xc9, 0x42, 0x7d, 0xa3, 0xb7, 0xb4, 0xf2, 0xe9, 0x37, 0xb1,
0x96, 0x42, 0x5a, 0x5f, 0x19, 0x7c, 0x25, 0xf7, 0xd0, 0xc5, 0x45, 0xfb,
0xfc, 0xd3, 0x2e, 0x6f, 0x23, 0xc1, 0x92, 0x76, 0x7b, 0xea, 0x6d, 0xf3,
0x38, 0x41, 0xf9, 0xbe, 0x29, 0x0c, 0xb5, 0xd2, 0x27, 0x15, 0xf5, 0x07