# How to change or disable the default banner in Spring Boot

By Atta Ur Rehman Shah (https://attacomsian.com/about). Published Feb 16, 2020, updated Sep 24, 2022. Topics: Spring Boot.
Canonical URL: https://attacomsian.com/blog/spring-boot-change-disable-banner

> A quick guide to learning how to customize the default banner or disable it completely in Spring Boot.

When you start a Spring Boot application, it displays an ASCII banner on the console. Here is what it looks like:

```bash
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.6.RELEASE)
```

In this short article, you'll learn how to **customize the startup banner** or **turn it off** in a Spring Boot application.

## Customizing Banner

Spring Boot accepts ASCII text, PNG, GIF, and JPG files as a custom startup banner. To **configure an ASCII banner**, all you need to do is create a new ASCII banner using an online tool like [Banner Generator](https://devops.datenkollektiv.de/banner.txt/index.html) and save it in `src/main/resources/banner.txt`  file. Spring Boot will automatically pick it up and display it as a startup banner.

There is **no specific format** required for this file. You can put any ASCII character there. Here is an example `banner.txt` file that contains the following ASCII banner:

<p class="file-desc"><span>banner.txt</span></p>

```plaintext
   ___  ______ ______   ___   _____  ____    __  ___   ____   ____   ___    _  __
  / _ |/_  __//_  __/  / _ | / ___/ / __ \  /  |/  /  / __/  /  _/  / _ |  / |/ /
 / __ | / /    / /    / __ |/ /__  / /_/ / / /|_/ /  _\ \   _/ /   / __ | /    /
/_/ |_|/_/    /_/    /_/ |_|\___/  \____/ /_/  /_/  /___/  /___/  /_/ |_|/_/|_/
${spring-boot.version} ----------------------------------------------------------
```

Now, if you run the Spring Boot application, it will output the following on the console:

```bash
   ___  ______ ______   ___   _____  ____    __  ___   ____   ____   ___    _  __
  / _ |/_  __//_  __/  / _ | / ___/ / __ \  /  |/  /  / __/  /  _/  / _ |  / |/ /
 / __ | / /    / /    / __ |/ /__  / /_/ / / /|_/ /  _\ \   _/ /   / __ | /    /
/_/ |_|/_/    /_/    /_/ |_|\___/  \____/ /_/  /_/  /___/  /___/  /_/ |_|/_/|_/
2.1.6.RELEASE -----------------------------------------------------------
```

You can even **specify a custom location** for the banner file by using the `application.properties` file:

```properties
spring.banner.location=classpath:static/banner.txt
```

### Custom Font and Background Color

You can also specify the font and background color of the ASCII banner as shown below:

```plaintext
${AnsiBackground.WHITE}${AnsiColor.GREEN}
   ___  ______ ______   ___   _____  ____    __  ___   ____   ____   ___    _  __
  / _ |/_  __//_  __/  / _ | / ___/ / __ \  /  |/  /  / __/  /  _/  / _ |  / |/ /
 / __ | / /    / /    / __ |/ /__  / /_/ / / /|_/ /  _\ \   _/ /   / __ | /    /
/_/ |_|/_/    /_/    /_/ |_|\___/  \____/ /_/  /_/  /___/  /___/  /_/ |_|/_/|_/
```

In the example above, we have chosen a white background and green color for the ASCII banner text.

### Using Banner Variables

Spring Boot provides several banner variables for use in your banner text file. Here is a list of available placeholders:

* `${application.title}` &mdash; The title of your application, as declared in MANIFEST.MF (if available)
* `${spring-boot.version}` &mdash; The Spring Boot version i.e. 2.1.6.RELEASE
* `${spring-boot.formatted-version}` &mdash; Formatted Spring Boot version i.e. (v2.2.0.BUILD-SNAPSHOT)
* `${application.version}` &mdash; The version number of your application, as declared in MANIFEST.MF, example 0.0.1.RELEASE
* `${application.formatted-version}` &mdash; The formatted version number of your application, as declared in MANIFEST.MF, example (v0.0.1)

The following example shows how you can use the above placeholders inside your ASCII banner file:

```plaintext
   ___  ______ ______   ___   _____  ____    __  ___   ____   ____   ___    _  __
  / _ |/_  __//_  __/  / _ | / ___/ / __ \  /  |/  /  / __/  /  _/  / _ |  / |/ /
 / __ | / /    / /    / __ |/ /__  / /_/ / / /|_/ /  _\ \   _/ /   / __ | /    /
/_/ |_|/_/    /_/    /_/ |_|\___/  \____/ /_/  /_/  /___/  /___/  /_/ |_|/_/|_/
Spring Boot ${spring-boot.version} ----------------------------------------------
${application.title} - ${application.formatted-version}
```

### Programmatically Generated Banner

You can also generate the startup banner on the fly in your Spring Boot application:

```java
@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(Application.class);
        app.setBanner((environment, sourceClass, out) -> {
            out.println("======= Welcome to My Blog =======");
        });
        app.run(args);
    }
		
}
```

## Disabling Banner

You can use the following methods to turn off the startup banner entirely when your Spring Boot application starts.

Add the following property in your `application.properties` file:

```properties
spring.main.banner-mode="off"
```

Or include the following to your `application.yml` file:

```yml
spring:
    main:
        banner-mode: "off"
```

Alternatively, you can also use the `SpringApplication.setBannerMode()` method in your main application class to disable the startup banner:

```java
public class Application {

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(Application.class);
        app.setBannerMode(Banner.Mode.OFF);
        app.run(args);
    }

}
```

Read [official documentation](https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-banner) to learn more about the startup banner in Spring Boot.
