Customize Spring Boot Startup Banner: Text, ASCII Art, and Images
This guide explains how to customize Spring Boot's startup banner using a banner.txt file, add ASCII art or dynamic variables, use image banners, and disable the banner via code or configuration, providing step‑by‑step instructions and examples.
When developing a Spring Boot project, you can replace the default startup banner with a custom banner.txt file to display any text, ASCII art, or dynamic variables.
Spring Boot documentation
1. What is banner.txt ?
banner.txtis a special text file in a Spring Boot project that defines the welcome message shown when the application starts. By default Spring Boot displays:
. ____ _ __ _ _
/\ / ___'_ __ _ _(_)_ __ __ _ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.6.13)By creating your own banner.txt, you can replace this text with any content, including ASCII art or variables.
2. How to create a banner.txt file?
1. Create the banner file (custom name supported)
Place a text file of any name under src/main/resources/, for example:
banner.txt (default)
my-banner.txt
banner-dev.txt
banner-prod.txt
If you use a non‑default name, specify its path in the configuration, e.g. for my-banner.txt:
spring:
banner:
location: my-banner.txt2. Add content
Paste ASCII characters directly into the file, such as:
.--. .--. .-''-. .-''-. .-------. .-'''-. .-./`) _____ __ .-./`) ____ __ .-./`) ,---. .--. .-_'''-.
| | _/ / .'_ _ \ .'_ _ \ | _ _ \ / _ \\ .-.')\ _\ / /\ .-.') \ \ / /\ .-.')| \ | | '_( )_ \
| (`' ) / / ( ` ) ' / ( ` ) '| ( ' ) | (`' )/`--'/ `-' \\.-./ ). / ' / `-' \ \ _. / ' / `-' \| , \ | ||(_ o _)| '
|(_ ()_) . (_ o _) |. (_ o _) ||(_ o _) / (_ o _). `-"`"`\ '_ .') .' `-"`"` _( )_ .' `-"`"`| |\_ \| |. (_,_)/___|
| (_,_) __ | (_,_)___|| (_,_)___|| (_,_).' __ (_,_). '. .---.(_ (_) _) ' .---. ___(_ o _)' .---. | _( )_\ || | .-----.
| |\ \ | |' \ .---.' \ .---.| |\ \ | |.---. \ : | | / \ \ | || |(_,_)' | | | (_ o _) |' \ '- .'
| | \ `' / \ `-' / \ `-' /| | \ `' /\ `-' | | | `-'`-' \ | || `-' / | | | (_,_)\ | \ `-'` |
| | \ / \ / \ / | | \ / \ / | | / / \ \ | \ / | | | | | | \ /
`--' `'-' `'-..-' `'-..-' ''-' `'-' `-...-' '---''--' '----''---' `-..-' '---' '--' '--' `'-...-'
${AnsiColor.RED}Spring Boot Version: ${spring-boot.version}${AnsiColor.DEFAULT}✅ Tip: Use online tools like Text to ASCII Art Generator (TAAG) or FIGlet to generate desired ASCII fonts.
Note: If the file encoding is not UTF‑8, set spring.banner.charset accordingly.
3. Dynamic variable injection
Spring Boot supports inserting dynamic variables (e.g., version) into banner.txt. Supported variables are shown in the image below.
Example:
.--. .--. .-''-. .-''-. .-------. .-'''-. .-./`) _____ __ .-./`) ____ __ .-./`) ,---. .--. .-_'''-.
| | _/ / .'_ _ \ .'_ _ \ | _ _ \ / _ \\ .-.')\ _\ / /\ .-.') \ \ / /\ .-.')| \ | | '_( )_ \
| (`' ) / / ( ` ) ' / ( ` ) '| ( ' ) | (`' )/`--'/ `-' \\.-./ ). / ' / `-' \ \ _. / ' / `-' \| , \ | ||(_ o _)| '
|(_ ()_) . (_ o _) |. (_ o _) ||(_ o _) / (_ o _). `-"`"`\ '_ .') .' `-"`"` _( )_ .' `-"`"`| |\_ \| |. (_,_)/___|
| (_,_) __ | (_,_)___|| (_,_)___|| (_,_).' __ (_,_). '. .---.(_ (_) _) ' .---. ___(_ o _)' .---. | _( )_\ || | .-----.
| |\ \ | |' \ .---.' \ .---.| |\ \ | |.---. \ : | | / \ \ | || |(_,_)' | | | (_ o _) |' \ '- .'
| | \ `' / \ `-' / \ `-' /| | \ `' /\ `-' | | | `-'`-' \ | || `-' / | | | (_,_)\ | \ `-'` |
| | \ / \ / \ / | | \ / \ / | | / / \ \ | \ / | | | | | | \ /
`--' `'-' `'-..-' `'-..-' ''-' `'-' `-...-' '---''--' '----''---' `-..-' '---' '--' '--' `'-...-'
${AnsiColor.RED}Spring Boot Version: ${spring-boot.version}${AnsiColor.DEFAULT}4. Use images as banner
Spring Boot can convert an image to ASCII characters for the startup banner.
1. Prepare the image
Place the image file under src/main/resources/. Spring Boot automatically reads and converts it.
Supported image file names (no extra config needed):
banner.gif
banner.jpg
banner.png
If you use a non‑default name or format (e.g., logo.jpg or app-banner.gif), specify the path in application.yml:
spring:
banner:
image:
location: classpath:images/app-banner.jpg
width: 30 # recommended not to exceed terminal width
height: 10 # character height
invert: false # false for light backgroundsNote:
Text banner and image banner can coexist.
Keep banner.txt for textual content (e.g., version, colors) and banner.png for logo or graphics.
Spring Boot shows the image banner first, then the text banner. If banner.gif, banner.jpg, and banner.png all exist and no explicit config is set, the order of precedence is gif > jpg > png.
2. View the effect on startup
Example:
The final printed result looks like this:
5. Disable banner
In production or audit environments you may want to hide the banner.
Method 1: Java code
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class BannerDemoApplication {
public static void main(String[] args) {
SpringApplication app = new SpringApplication(BannerDemoApplication.class);
app.setBannerMode(Banner.Mode.OFF);
app.run(args);
}
}This approach can be overridden by configuration.
Method 2: Configuration file
spring:
main:
banner-mode: OFFSelected Java Interview Questions
A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
