> ## Content Index
> Fetch the complete content index at: https://linuxhandbook.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Convert Hex to ASCII Characters in Linux Command Line
- URL: https://linuxhandbook.com/convert-hex-ascii/
- Published: 2022-07-13T05:18:19.000Z
- Updated: 2025-07-27T13:10:18.000Z
- Description: Here are various ways for converting Hex to ASCII characters in the Linux command line and bash scripts.
- Author: Abhishek Prakash
- Tags: Quick Tip

Got a bunch of hexadecimal characters and want to convert them to a readable decimal system (ASCII)?

There are multiple ways to convert hex to ASCII in Linux. You may also use these methods in your shell script if required. 

## Converting Hexadecimal to ASCII in Linux

Hexadecimal is a number system in which you use a combination of numbers (0-9) to represent values ranging from 0 to 9 and alphabets (A-F) to represent values from 10 to 15.

It may sound complicated but it is still better than binary numbering where everything is 1 and 0.

Hex was extensively used in microcontrollers a few decades ago. You could still see it in use, especially with the Hex color pallet which is used to represent various shades of colors.

On the other hand, ASCII stands for American Standard Code for Information Interchange and has a completely different use case than Hexadecimal. ASCII is a method that is used to convert normal language characters to binary so computers can understand instructions from our side.

Through this guide, I will include various ways by which you can easily convert hex to ASCII.

![Convert hex to ascii in Linux](https://linuxhandbook.com/content/images/2022/07/hex-ascii-conversion-linux.png)

Let's consider the following hex code (problem statement) which I want to convert:

```Hexadecimal
4c696e757868616e64626f6f6b20313233
```

And if I succeed in converting the above hex code, the ASCII conversion should look like this:

```ASCII
Linuxhandbook 123
```

### Method 1: Using xxd Command

xxd is a command-line utility that can create a hex dump from the given text and vice versa.

First I'm going to input hex string [using echo command](https://linuxhandbook.com/echo-command/) and will pair it with xxd using pipe.

```
echo 4c696e757868616e64626f6f6b20313233 | xxd -r -p
```

Here, command option -r is used to convert hex code to ASCII, and -p is used to print the plain text. 

```
sagar@itsfoss:~$ echo 4c696e757868616e64626f6f6b20313233 | xxd -r -p 
Linuxhandbook 123sagar@itsfoss:~$ 

```

As you can see above, the output gets mixed with the prompt in the terminal because the converted output doesn't have the new line character. ***To make it more readable, you may append `echo ''` to the above command.***

```
echo 4c696e757868616e64626f6f6b20313233 | xxd -r -p && echo ''
```

![](https://linuxhandbook.com/content/images/2022/07/Using-xdd-command.png)

Converting hex to ASCII using xxd

### Method 2: Using printf Command

Yes, you can convert hex to ASCII [using the bash printf command](https://linuxhandbook.com/bash-printf/). Here, I'm going to use the \\x option which will take input of 1 or two digits as shown below: 

```
printf '\x4c\x69\x6e\x75\x78\x68\x61\x6e\x64\x62\x6f\x6f\x6b\x20\x31\x32\x33'
```

There is no issue if you get a single digit at the end of the hex string and it will work fine as demonstrated.

![](https://linuxhandbook.com/content/images/2022/07/using-printf-command.png)

Converting hex to ASCII using printf

### Method 3: Using dc Command

You might be wondering how we can use deck calculator (dc) for converting hex to ASCII and I will show you exactly how.

```
echo "16i 4C696E757868616E64626F6F6B20313233 P" | dc
```

Here, **16i** is used to indicate that you are dealing with hex radix, and **P** is used to print output from the dc command. 

By using the above command, you will get a similar result as given below:

![](https://linuxhandbook.com/content/images/2022/07/using-dc-command.png)

Converting hex to ASCII using dc

### Method 4: Using Perl Command

So if your system has Perl installed, you can easily convert hex to ASCII using this method. Just interchange my hex code with yours in the given command and that's it.

```
echo 4c696e757868616e64626f6f6b20313233 | perl -ne 's/([0-9a-f]{2})/print chr hex $1/gie' && echo ''
```

And you'll be met with the results as shown below:

![](https://linuxhandbook.com/content/images/2022/07/using-perl-command.png)

Converting hex to ASCII using Perl

### Method 5: Using sed Command

This method is a bit similar to the above but here you are [using sed](https://linuxhandbook.com/sed-command-basics/) to filter and convert hex to ASCII using normal expression.

```
echo -n 4c696e757868616e64626f6f6b20313233 | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo ''

```

By using piping, we collected hash string through echo, converted it by pairing sed to given expression, and got output as given.

![](https://linuxhandbook.com/content/images/2022/07/using-sed-command.png)

Converting hex to ASCII using sed

### Method 6: Convert hex strings stored in text file

So if you have a hex string stored under a text file, you can use this method to convert the stored hex string to ASCII. 

My hex string is stored in a hex.txt file so to convert that string, I'll have to follow the given command:

```
cat hex.txt | xxd -r -p && echo ''
```

By far this is the most convenient way as you don't have to enter hex strings again and again and the best part is you can store multiple hex strings and convert them using the same command.

![](https://linuxhandbook.com/content/images/2022/07/using-cat-command.png)

Converting hex to ASCII using hex file

This was my take on how you can convert hex string to ASCII using various methods. By far, the last one is my favorite as it is quite efficient compared to the others.

There are dedicated Hex editors in Linux and you may try them as well if you want. 

[Top 5 Hex Editors for Linux \[GUI and CLI Tools\]Here are our choices for the best hex editors for Linux. The list includes both GUI and command line based Linux hex editors.![](https://itsfoss.com/wp-content/uploads/2017/06/cropped-Logo-redsigned-without-name-270x270.png)It's FOSSAnkush Das![](https://itsfoss.com/wp-content/uploads/2019/01/Linux-hex-editors.jpeg)](https://itsfoss.com/hex-editors-linux/?ref=linuxhandbook.com)

In fact, you can also [convert Hex to ASCII online with the free tool](https://linuxhandbook.com/tools/hex-ascii-converter/).

## Hex to ASCII Converter

Convert hexadecimal values to readable ASCII text

Hexadecimal Input 

Convert Clear All Copy Result 

ASCII Output 

### Supported Formats

This tool accepts hexadecimal input in various formats:

• Continuous: 48656c6c6f20576f726c64  
• Space-separated: 48 65 6c 6c 6f 20 57 6f 72 6c 64  
• With 0x prefix: 0x48 0x65 0x6c 0x6c 0x6f  
• Mixed case: 48656C6C6F20576F726C64 

Made by [Linux Handbook](https://linuxhandbook.com/)