Partner – Moderne – NPI EA (cat=Spring Boot)
announcement - icon

Refactor Java code safely — and automatically — with OpenRewrite.

Refactoring big codebases by hand is slow, risky, and easy to put off. That’s where OpenRewrite comes in. The open-source framework for large-scale, automated code transformations helps teams modernize safely and consistently.

Each month, the creators and maintainers of OpenRewrite at Moderne run live, hands-on training sessions — one for newcomers and one for experienced users. You’ll see how recipes work, how to apply them across projects, and how to modernize code with confidence.

Join the next session, bring your questions, and learn how to automate the kind of work that usually eats your sprint time.

Course – Black Friday 2026 – NPI EA – main – before_post_content
announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

Course – Black Friday 2026 – NPI – main – before_post_content
announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

1. Introduction

One of the endearing features of Spring Boot is its startup banner. Over the years, Spring Boot has evolved to support various types of banners. For example, both text and background color support were added for banners in Spring Boot 1.3.

In this quick tutorial, we’ll look at Spring Boot’s color banner support and how to use it.

2. Changing Background Color

To add a background color to a Spring Boot banner, we simply need to prefix lines of banner.txt with the desired color code, using the AnsiBackground class.

For example, let’s create a banner.txt file to make the entire background red:

${AnsiBackground.RED}
  ___         _   _      _ 
 / __|  ___  | | (_)  __| |
 \__ \ / _ \ | | | | / _` |
 |___/ \___/ |_| |_| \__,_|
${AnsiBackground.DEFAULT}
spring boot color banner solid background

In fact, we can use as many background colors as we want in a single banner.

For example, we could set each line to its own background color. We simply prefix each line with the desired color:

${AnsiBackground.RED}    ____             _             __
${AnsiBackground.BLUE}   / __ \  ____ _   (_)   ____    / /_   ____  _      __
${AnsiBackground.YELLOW}  / /_/ / / __ `/  / /   / __ \  / __ \ / __ \| | /| / /
${AnsiBackground.GREEN} / _, _/ / /_/ /  / /   / / / / / /_/ // /_/ /| |/ |/ /
${AnsiBackground.MAGENTA}/_/ |_|  \__,_/  /_/   /_/ /_/ /_.___/ \____/ |__/|__/
${AnsiBackground.DEFAULT}
spring boot color banner rainbow background

It’s important to remember that all of our application logging will use the last background color specified in banner.txt. Therefore, it’s a best practice to always end the banner.txt file with the default color.

3. Changing Text Color

To change the color of the text, we can use the AnsiColor class. Just like the AnsiBackground class, it has predefined color constants we can choose from.

We simply prefix each group of characters with the desired color:

${AnsiColor.RED}.------.${AnsiColor.BLACK}.------.
${AnsiColor.RED}|A.--. |${AnsiColor.BLACK}|K.--. |
${AnsiColor.RED}| (\/) |${AnsiColor.BLACK}| (\/) |
${AnsiColor.RED}| :\/: |${AnsiColor.BLACK}| :\/: |
${AnsiColor.RED}| '--'A|${AnsiColor.BLACK}| '--'K|
${AnsiColor.RED}`------'${AnsiColor.BLACK}`------'
${AnsiColor.DEFAULT}
spring boot color text

As with background color, it’s important that the last line of the banner always resets the color to default.

4. ANSI 8-Bit Color

One of the new features in Spring Boot 2.2 is support for ANSI 8-bit colors. Instead of being limited to a handful of predefined colors, we can specify both text and background colors using the full range of 256 colors.

To utilize the new colors, both the AnsiColor and AnsiBackground properties now accept a numerical value instead of a color name:

${AnsiColor.1}${AnsiBackground.233}  ______  __________ .___ ___________
${AnsiBackground.235} /  __  \ \______   \|   |\__    ___/
${AnsiBackground.237} >      <  |    |  _/|   |  |    |
${AnsiBackground.239}/   --   \ |    |   \|   |  |    |
${AnsiBackground.241}\______  / |______  /|___|  |____|
${AnsiBackground.243}       \/         \/
${AnsiBackground.DEFAULT}${AnsiColor.DEFAULT}
spring boot color banner 8 bit ansi

Notice that we can mix both text and background properties however we want. We can even mix the new 8-bit color codes and older color constants in the same banner.

5. Conclusion

In this article, we’ve seen how to change both the text and background colors of the Spring Boot banner.

We also saw how newer versions of Spring Boot support ANSI 8-bit color codes.

Partner – Moderne – NPI EA (tag=Refactoring)
announcement - icon

Modern Java teams move fast — but codebases don’t always keep up. Frameworks change, dependencies drift, and tech debt builds until it starts to drag on delivery. OpenRewrite was built to fix that: an open-source refactoring engine that automates repetitive code changes while keeping developer intent intact.

The monthly training series, led by the creators and maintainers of OpenRewrite at Moderne, walks through real-world migrations and modernization patterns. Whether you’re new to recipes or ready to write your own, you’ll learn practical ways to refactor safely and at scale.

If you’ve ever wished refactoring felt as natural — and as fast — as writing code, this is a good place to start.

Course – Black Friday 2026 – NPI EA – main – after_post_content

announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

Course – Black Friday 2026 – NPI – main – after_post_content

announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW