Converting Hex to String in Java

In this example, we will show you the simple program about, how to convert hex to string in Java. The example program has been tested and shared in the same post.

Example Program (

package com.dineshkrish;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
* @author Dinesh Krishnan
public class Converter {
public static String convert(String hex) {
byte[] bytes = null;
String output = null;
try {
bytes = Hex.decodeHex(hex.toCharArray());
output = new String(bytes, "UTF-8");
} catch (DecoderException e) {
} catch (UnsupportedEncodingException e) {
return output;
public static void main(String[] args) {
String input = "44696e657368204b726973686e616e";
String output = convert(input);
System.out.println("Converted ---> "+output);

Maven Dependencies (pom.xml)

<project xmlns="" xmlns:xsi=""


Converted ---> Dinesh Krishnan

No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *