StringUtils.isBlank() checks that each character of the string is a whitespace character (or that the string is empty or that it's null). This is totally different than just checking if the string is empty.

From the linked documentation:

Checks if a String is whitespace, empty ("") or null.

 StringUtils.isBlank(null)      = true
 StringUtils.isBlank("")        = true  
 StringUtils.isBlank(" ")       = true  
 StringUtils.isBlank("bob")     = false  
 StringUtils.isBlank("  bob  ") = false

For comparison StringUtils.isEmpty:

 StringUtils.isEmpty(null)      = true
 StringUtils.isEmpty("")        = true  
 StringUtils.isEmpty(" ")       = false  
 StringUtils.isEmpty("bob")     = false  
 StringUtils.isEmpty("  bob  ") = false

Warning: In java.lang.String.isBlank() and java.lang.String.isEmpty() work the same except they don't return true for null.

java.lang.String.isBlank() (since Java 11)

java.lang.String.isEmpty()

Answer from arshajii on Stack Overflow
🌐
Baeldung
baeldung.com › home › java › java string › checking for empty or blank strings in java
Checking for Empty or Blank Strings in Java | Baeldung
January 8, 2024 - Like Guava, it won’t check if a string only contains whitespace but checks whether a given string is null or empty. There are several ways to check whether a string is empty or not.
🌐
Medium
medium.com › @lp.lok.payu › isempty-vs-empty-vs-isblank-vs-isnull-12aea580fe4b
isEmpty() vs empty() vs isBlank() vs isNull() | by leela prasad | Medium
February 16, 2025 - String str = " "; if (str.isBlank()) { System.out.println("String is blank"); } Checks if the value is null, empty, or contains only whitespace characters. ... Returns true if the string is null, empty, or only whitespace.
🌐
Reddit
reddit.com › r/askprogramming › in java, should i use (string ) isempty() or isblank() when checking an xml object for an empty value?
r/AskProgramming on Reddit: In Java, should I use (String ) isEmpty() or isBlank() when checking an XML object for an empty value?
September 26, 2022 -

I have some config file and it is deployed in many regions. Some regions have certain requirements for example lets say one region needed a username and password (basic auth). The current setup is that each deployment has it's own config file and only the instances where it is needed are these values included in the respective config.xml file.

So I have in my Java code some logic that says

'if this element is in the XML, set the corresponding variable with its value, if not do nothing'

So when I'm trying to see if that value is present or if the tag is empty/blank, which String utility should I use to check?

example code (default option left open as empty string):

if (my_config.getString(USER_ID_ELEMENT, "") != null
    & my_config.getString(PASSWORD_ELEMENT, "") != null) {
		my_userId = m_config.getString(USER_ID_ELEMENT, "");
		my_password = m_config.getString(PASSWORD_ELEMENT, "");

Here I'm checking if it is not null, but I don't think it's a very good test since I don't know if an empty XML tag is blank or is empty (i think null isn't even an option)?

🌐
Educative
educative.io › answers › what-is-stringutilsisblank-in-java
What is StringUtils.isBlank in Java?
If a string satisfies any of the criteria below, then the string is considered to be blank: The length of the string is zero or the string is empty. The string points to a null reference.
🌐
Baeldung
baeldung.com › home › java › java string › difference between string isempty() and isblank()
Difference Between String isEmpty() and isBlank() | Baeldung
December 2, 2025 - Additionally, the escape sequences \t, \n, \r, \f, and \s are considered whitespace characters, so only isBlank() returns true. In contrast, isEmpty() returns false for all of them. Finally, for any other character different from the ones shown in the table, both methods return false. Before Java 11, developers typically used the combination of String.trim() and String.isEmpty() to validate that a text contains only whitespace characters.
🌐
Vultr Docs
docs.vultr.com › java › examples › check-if-a-string-is-empty-or-null
Java Program to Check if a String is Empty or Null | Vultr Docs
December 17, 2024 - Here, StringUtils.isBlank() checks if str is null, empty, or made solely of whitespace (spaces, tabs, new line characters). Very useful when the mere presence of whitespace should also classify the string as "empty".
Find elsewhere
🌐
Medium
medium.com › @AlexanderObregon › javas-string-isblank-method-explained-be7064a144a7
Java’s String.isBlank() Method Explained | Medium
January 10, 2025 - With isBlank(), these checks are more direct. Consider the traditional way of validating a string for meaningful content: if (input == null || input.trim().isEmpty()) { System.out.println("Invalid input"); } With isBlank(): if (input == null || input.isBlank()) { System.out.println("Invalid input"); } Benefits of using isBlank() in conditional logic: Fewer manual steps such as trimming or chaining conditions.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-string-isblank-method
Java String isBlank() Method - GeeksforGeeks
July 23, 2025 - Example 3: This example shows how to use isBlank() with conditional logic to handle blank inputs in an application. ... // Java program to use isBlank() with conditional logic public class StringIsBlank { public static void main(String[] args) { // String with spaces String s = " "; // Check if the message is blank if (s.isBlank()) { System.out.println("The message is blank."); } else { System.out.println("Message: " + s); } } }
🌐
CodeGym
codegym.cc › java blog › strings in java › java: check if string is null, empty or blank
Java: Check if String is Null, Empty or Blank
October 11, 2023 - " + myName.isBlank()); myName = myName.concat("Lubaina Khan"); if (!myName.isEmpty()) { System.out.println("The String = " + myName); } } } The String = Is the String null? false Is the String empty? false Is the String blank? true The String = Lubaina Khan · Here was a quick run down on how a null, empty and blank Strings can be spotted and checked in Java.
🌐
Stack Abuse
stackabuse.com › java-check-if-string-is-null-empty-or-blank
Java: Check if String is Null, Empty or Blank
February 28, 2023 - String string = "Hello there"; if (string == null || string.equals("") || string.trim().equals("")) System.out.println("String is null, empty or blank"); else System.out.println("String is neither null, empty nor blank"); In much the same fashion as the before, if the trimmed string is "", it was either empty from the get-go, or was a blank string with 0..n whitespaces: ... The Apache Commons is a popular Java library that provides further functionality.
🌐
Sumo Logic
sumologic.com › log search › search query language › search operators › isnull, isempty, isblank
isNull, isEmpty, isBlank Search Operators | Sumo Logic Docs
The isEmpty operator checks if a string contains no characters and is only whitespace. The isBlank operator checks if a string contains no characters, is only whitespace, and is null.
🌐
TutorialsPoint
tutorialspoint.com › Checking-for-Null-or-Empty-in-Java
Checking for Null or Empty in Java.
The following is an example of ... } } } ... The string is not empty. We can check whether a particular String is empty or not, using the isBlank() method of the StringUtils class....
🌐
Tutorialspoint
tutorialspoint.com › home › java/lang › java string isblank method
Java String isBlank Method
September 1, 2008 - The given string is: TutorialsPoint The string length is: 14 The isBlank() method returns: false The string is not a blank string. If the given string value is a null, this method throws a NullPointerException.
🌐
O'Reilly
oreilly.com › library › view › jakarta-commons-cookbook › 059600706X › ch02s03.html
2.2. Checking for an Empty String - Jakarta Commons Cookbook [Book]
November 16, 2004 - You need to test for an empty or null string. Use StringUtils.isBlank() . This method will return true if it is supplied with an empty, zero length, or whitespace-only string. This method gracefully handles a null input by returning true.
Author   Timothy M. O'Brien
Published   2004
Pages   400
🌐
HowToDoInJava
howtodoinjava.com › home › java 11 › java string isblank() – check blank or empty string
Java String isBlank() - Check Blank or Empty String
December 12, 2022 - The isBlank() method has been added in Java 11. To check if a given string does not have even blank spaces, use String.isEmpty() method. It returns true if the given string is empty or contains only white space code points, otherwise false. It uses Character.isWhitespace(char) method to determine a white space character.
🌐
iO Flood
ioflood.com › blog › stringutils-isempty
StringUtils.isEmpty() in Java: Your Method Guide
March 27, 2024 - Understanding the difference between null and empty strings is crucial when working with StringUtils.isEmpty, as this method checks for both conditions. It returns true if the string is either null or empty, and false otherwise. StringUtils.isEmpty plays a crucial role in string manipulation tasks in Java applications.