Skip to main content
Code blocks are essential for technical documentation. Mintlify provides powerful syntax highlighting and code formatting capabilities for over 100 programming languages.

Inline code

To denote a word or phrase as code, enclose it in backticks (`).
To denote a `word` or `phrase` as code, enclose it in backticks (`).
Use inline code formatting for file names, commands, function names, and short code snippets within sentences.

Code blocks

Use fenced code blocks by enclosing code in three backticks and follow the leading ticks with the programming language of your snippet to get syntax highlighting.

Basic code block

Add the programming language after the opening backticks for syntax highlighting:
class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
```java
class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
```

Code block with filename

Optionally, you can also write the name of your code file after the programming language:
HelloWorld.java
class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
```java HelloWorld.java
class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
```
Displaying the filename helps readers understand the context and location of the code.

Multiple code examples

Use the CodeGroup component to show multiple related code examples with tabs:
function greet(name) {
  console.log(`Hello, ${name}!`);
}

greet("World");
CodeGroup is perfect for showing the same functionality across different programming languages or different approaches to solving the same problem.

Supported languages

Mintlify supports syntax highlighting for over 100 programming languages including:
Simply specify the language name after the opening backticks to enable syntax highlighting for that language.

Build docs developers (and LLMs) love