Base64 Encoding Performance: JDK vs Apache Commons

A runner with T-Shirt “j.u.Base64” crosses the finish line

Recently I stumbled upon some old code that used Base64 from Apache Commons. So I decided to compare its performance to java.util.Base64.

It’s not a new topic whatsoever (links at the end), so let’s just jump to benchmark results.


Performance for encoding 10K characters for different JDKs. java.util.Base64 is a clear winner performing almost 10x faster.

A bar chart for all JDKs

Performance for different data sizes (from 1 byte to 10K bytes) for openjdk-17. As you could see in the previous chart, openjdk-8 performs worse, but still java.util.Base64 is clearly better in all cases.

A line chart for all data lenghts


It’s clearly a time to replace old usages of Apache Commons for base64 encoding. Unless you are on JDK7 or lower, then it’s time to upgrade this part first ;-) (as java.util.Base64 was introduced in JDK8)

Read More

Play with charts here. Source code is on GitHub.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Dmitry Komanov

Dmitry Komanov


Software developer, moved to Israel from Russia, trying to be aware of things.