CLI tool
ajalt/mordant avatar
ajalt/mordant

Mordant, the Kotlin terminal styling library, and where its JVM builds split

Multiplatform text styling for Kotlin command-line applications

1,247 stars51 forksKotlinApache-2.0

At a glance

What is it?
Mordant is a multiplatform Kotlin library for styled terminal output, widgets, animations and Markdown, published on Maven Central. The useful part is automatic terminal capability detection; the cost is that the JVM side is split across several interop flavoured artifacts with little guidance in the README.
Who is it for?
Adopt Mordant if you build command-line tools in Kotlin and want styled text, tables, progress animation and Markdown without hand-writing ANSI detection. Do not reach for it if your project is not on Kotlin, or if you are actually building a full screen terminal interface, since Mordant is a rendering and layout library rather than an event loop.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 53 days ago.
What is it written in?
Mainly Kotlin, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 22, 2026, and from our analysis. They are not legal advice.

Editorial analysis

Automatic capability detection instead of hardcoded escape codes

Mordant is a multiplatform library for rendering styled text in the terminal, written in Kotlin. What it replaces is the habit of printing raw escape sequences and hoping the other end understands them. The project lists easy colorful ANSI output with automatic detection of terminal capabilities as its first headline feature, and that detection is the part worth caring about. A program that cannot tell whether the destination handles color, or how much color it handles, ends up writing escape sequences into log files, into CI output, or down a pipe into another program.

The repository backs that claim with a dedicated sample. There is a samples/detection/ directory among the sample projects, which suggests the detection path is meant to be exercised and inspected rather than taken on faith. For a library whose entire job is output formatting, that is the correct place to put the effort, and it is the reason to reach for Mordant instead of pasting ANSI codes into a string builder by hand.

One Maven Central coordinate plus two optional artifacts

Mordant is distributed through Maven Central, and the dependency block is short. The core library, the coroutine extension for animations and the Markdown widget are all published under the same group and version, so a project that starts with the core can add the other two later without juggling versions.

kotlin
dependencies {
    implementation("com.github.ajalt.mordant:mordant:3.1.0")

    // optional extensions for running animations with coroutines
    implementation("com.github.ajalt.mordant:mordant-coroutines:3.1.0")

    // optional widget for rendering Markdown
    implementation("com.github.ajalt.mordant:mordant-markdown:3.1.0")
}

The core dependency alone is enough for styled text and widgets. The README also notes one wrinkle for Gradle and Maven users: if you build with Maven rather than Gradle, use the artifactId mordant-jvm, and on the JVM there are more granular dependencies available, with the details left to the documentation site rather than the README.

Widgets for tables and panels, with a sample tree as the real reference

Beyond colored text, Mordant offers widgets for laying out terminal output, including lists, tables, panels and more. That is the part of the library that changes how a CLI reads, since a table rendered as aligned columns is a different artifact from a table printed by hand with string padding.

The sample directories map the feature surface almost one to one: samples/drawing/, samples/hexviewer/, samples/markdown/, samples/progress/, samples/select/, samples/table/ and samples/tour/, alongside samples/detection/. There is a hex viewer and a select widget here, which tells you the library reaches past formatting into interactive and inspection helpers. The tour sample is the one to read first, since it reads like a guided walk through the widget set. The trade-off is that the README is deliberately short, so the sample tree and the documentation site do the work the README leaves out.

Animations cover any widget, and coroutines are an opt-in dependency

The project claims support for animating any widget, with progress bars and dashboards given as examples. That is a broader promise than a progress bar library makes, and it is why the animation support ships as a separate optional artifact, mordant-coroutines, rather than inside the core. The choice is sensible for a library that targets many platforms, since coroutine support is exactly the kind of thing that pulls a dependency tree into a project that only wanted colored text.

In practice the shape of usage is straightforward. The samples/progress/ directory shows the intended case, and the progress bar and dashboard examples are the ones most projects will reach for first. If a project has no coroutines in its build, the core artifact still delivers widgets and styling, and the animation path is simply not available.

Markdown rendering arrives as its own widget

Rendering Markdown directly to the terminal is a separate capability in Mordant, and it comes as the optional mordant-markdown artifact rather than being folded into the core. The trade-off here is one of weight: a Markdown renderer is a dependency nobody wants in a command-line tool that only needs a colored help message.

The samples/markdown/ directory is the reference for what the widget can do, and the project page links to the documentation site for the details. Whether the rendering handles everything a Markdown author expects, from tables to nested lists, is something the sample directory can tell you and this overview cannot. The practical point for an adopter is simple: adding the widget is a one line dependency change, and the version follows the same train as the rest of the library.

The JVM build splits three ways and the README stays quiet about it

Look at the top level of the repository and the JVM side is visibly fragmented. Alongside the core mordant/ directory there is mordant-jvm-ffm/, mordant-jvm-graal-ffi/ and mordant-jvm-jna/, plus mordant-omnibus/ and the two optional modules. The directory names point at different native interop approaches for reaching the terminal on the JVM.

The documentation gap is the notable part. The README says only that on the JVM there are more granular dependencies available and points to the guide; it does not say which artifact to use for which runtime. The result is a concrete adoption risk: a project that guesses wrong ends up depending on an interop layer its runtime does not support, and the fix is a coordinate change rather than a code change, but it is a coordinate change you make after a failed build. mordant-omnibus/ suggests an all in one artifact exists, though the README does not describe it. In this repository the layout tells you more than the prose does.

Snapshot builds need their own repository entry

Release artifacts come from Maven Central, and there is a second channel for people who want to track the development branch. Snapshot builds are published to the Central Portal snapshots repository, which has to be declared before Gradle can resolve them.

kotlin
repositories {
    maven {
        url = uri("https://central.sonatype.com/repository/maven-snapshots/")
    }
}

The block is small and the URL is fixed, so the setup cost is one repository entry. What it buys is a moving target, which is worth naming plainly: a snapshot resolves to a fresh build each time it is requested, so a build that passed yesterday can pull different bytecode today. Teams that pin a version should stay on the released 3.1.0 artifact, and use the snapshot repository only when they are deliberately testing unreleased changes.

Apache-2.0, version 3.1.0, and a last push on 2026-08-31

The project is licensed under Apache License 2.0, copyright 2018 AJ Alt, with the licence text stored in LICENSE.txt at the root of the repository. Apache 2.0 is a permissive licence with an explicit patent grant, which for a library that other projects vendor into their own tools means the obligations stay light: keep the licence and the notices, and mark modified files when you distribute them.

On maintenance, the repository is not archived and the last push was on 2026-08-31, the same day release 3.1.0 was published. Before that came 3.0.2 from 2025-02-15 and 3.0.1 from 2024-11-02. The gap between the 3.0.2 and 3.1.0 tags is long, and a jump to a new minor version is worth a read of CHANGELOG.md before you bump the coordinate in a project that has many dependents.

Editorial conclusion

Adopt Mordant if you build command-line tools in Kotlin and want styled text, tables, progress animation and Markdown without hand-writing ANSI detection. Do not reach for it if your project is not on Kotlin, or if you are actually building a full screen terminal interface, since Mordant is a rendering and layout library rather than an event loop. Before you commit, check the guide for which JVM artifact to depend on, because the repository ships mordant-jvm-ffm, mordant-jvm-graal-ffi and mordant-jvm-jna without saying which one your runtime supports, and the plain mordant coordinate is the safe starting point at 3.1.0.

Frequently asked questions

Which Mordant dependency do I add to a Kotlin project?

Add implementation("com.github.ajalt.mordant:mordant:3.1.0") from Maven Central. The coroutine and Markdown pieces are separate optional artifacts, mordant-coroutines and mordant-markdown.

I build with Maven instead of Gradle. Which Mordant artifact do I use?

The README says to use the artifactId mordant-jvm when using Maven rather than Gradle. It also notes that more granular dependencies are available on the JVM, with the details in the guide at ajalt.github.io/mordant.

Does Mordant detect whether the terminal supports color?

Yes. The project lists easy colorful ANSI output with automatic detection of terminal capabilities as a headline feature, and the samples/detection/ directory exists to exercise that path.

How do I run a progress bar animation in Mordant?

Mordant supports animating any widget, with progress bars and dashboards as examples, and the optional mordant-coroutines artifact provides the extensions for running animations with coroutines. The samples/progress/ directory shows the intended usage.

How do I install a Mordant snapshot build?

Add the Central Portal snapshots repository to your build with the url https://central.sonatype.com/repository/maven-snapshots/ and Gradle will resolve snapshots from there. Released versions come from Maven Central as usual.

What licence is Mordant published under?

Apache License 2.0, copyright 2018 AJ Alt, with the full text in LICENSE.txt. It is a permissive licence, so vendoring it into a proprietary command-line tool keeps the obligations light.

Official sources

  1. ajalt/mordant on GitHub
  2. License: Apache-2.0
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/ajalt-mordant.svg)](https://hysenlabs.com/projects/ajalt-mordant)

Was this useful?