Terminal Markdown Viewer: Read MD Files from the CLI

To view Markdown in the terminal, use less README.md for the source or a Markdown reader such as Glow for formatted headings, lists, and code. For a long file, glow -p README.md opens a rendered view in a pager after Glow is installed.

A terminal MD reader is useful over SSH or while working in a repository. If the document contains Mermaid diagrams, check whether your chosen reader renders them; Markdown formatting alone does not guarantee diagram support.

The Fastest Commands for Reading an MD File

Markdown does not require a special program. It is UTF-8 text, so the standard terminal tools work everywhere:

cat README.md
less README.md

cat prints the whole file and is useful for short notes or scripts. less is better for a long README because it lets you scroll, search with /, jump with g and G, and quit with q.

If you want line numbers while diagnosing a broken block, use:

less -N architecture.md

These commands display Markdown source. You will see characters such as #, backticks, pipes, and link destinations. That is often desirable during editing, but it is different from a rendered document.

Source View Versus Rendered View

The right tool depends on the question you are asking.

Task Source in less Terminal renderer Browser renderer
Search for text Excellent Good Good
Check exact syntax Excellent Limited Limited
Read headings and lists Acceptable Good Good
Read wide tables Difficult Varies Good
View local images No Varies Good
Render Mermaid No Tool/version dependent Yes
Render LaTeX math No Tool/version dependent Yes
Print or save as PDF No No Yes

A source view tells you exactly what is in the file. A rendered view tells you what a reader will see. Technical documents usually need both checks.

Terminal Markdown Viewer Options

Choose a reader according to whether you need exact source, formatted terminal output, or an editor preview.

Tool Example Best fit
less less -N README.md Source inspection, line numbers, search, remote machines
Glow glow -p README.md Formatted Markdown in a terminal pager
Rich CLI rich README.md --markdown --pager Formatted Markdown with a built-in pager
Neovim preview plugin :MarkdownPreview Browser preview while editing, including Mermaid with a supporting plugin

Read Markdown with Glow

Glow is a terminal Markdown reader. On a machine with Homebrew, install it with brew install glow; other platform installation options are in the project's README. Then run:

glow README.md
glow -p README.md

The first command prints formatted content; the second enables paging. Run glow without a file to browse Markdown files through its terminal interface. Check glow --help for the options in your installed version.

Read Markdown with Rich CLI

If you already use Python and pipx, install Rich CLI in an isolated application environment:

pipx install rich-cli
rich README.md --markdown --pager

--markdown selects Markdown rendering and --pager keeps a long document scrollable. Installing this package creates the rich command. If it is not found after installation, check pipx's application directory is on your PATH.

mdcat on Ubuntu: Check Which Version You Have

If mdcat is installed, start with:

mdcat --version
mdcat --help
mdcat README.md

The original swsnr/mdcat repository is archived and points to BIRSAx2/mdcat as a maintained fork. The fork documents Mermaid, math, and image rendering, including terminal-dependent fallbacks. An older Ubuntu package may behave differently; do not assume the fork's features are present merely because the executable is named mdcat.

Check the installed package and candidate version before changing it:

apt-cache policy mdcat

If your configured repositories provide the version you want, use your normal package-management process. Otherwise consult the fork's release instructions. Test a small diagram and formula in your actual terminal: an SSH session, image protocol, or older binary can change the result. mdcat's documented --watch option in the maintained fork refreshes the preview after saves; it does not edit the file.

Edit Markdown in the Terminal

Reading and editing are separate tasks. For a basic source edit with GNU nano installed:

nano README.md

Change the Markdown, press Ctrl+O, confirm the filename with Enter, and press Ctrl+X to exit. These shortcuts are listed in the GNU nano reference. Then rerun your reader and inspect the diff:

glow -p README.md
git diff -- README.md

The Git command applies inside a repository. A rendered preview helps spot formatting problems, while the diff shows the exact text changed. For an editor with a browser preview that follows your edits, use the focused Neovim or Emacs guides below.

Preview from a Terminal Editor

For a live browser preview from Neovim, follow the Neovim Mermaid setup guide. Emacs users can compile Mermaid diagrams or preview Markdown. These editor workflows differ from displaying formatted text directly inside terminal cells.

Test a real document before choosing a reader. Check wide tables, nested lists, images, and diagrams separately rather than assuming one working heading proves complete Markdown support.

Why Mermaid Is Different in a Terminal

A Mermaid block is source code for a diagram:

```mermaid
flowchart LR
  Source[Markdown source] --> Parser
  Parser --> Diagram[Rendered diagram]
```

A basic command-line MD viewer can color that block, but producing the diagram requires a Mermaid parser and a graphical rendering environment. Terminal cells are designed for characters, not an interactive SVG canvas. Some workflows render Mermaid to an image first and then use a terminal image protocol, but that adds dependencies and behaves differently across terminal applications.

For a document containing diagrams, use the terminal to inspect or edit the source, then open the complete Markdown document in a renderer with Mermaid support. The existing guide to a Markdown viewer with Mermaid support explains what to test beyond a single diagram.

Can a Terminal Markdown Reader Render Mermaid?

Some readers show Mermaid as highlighted source; the maintained mdcat fork documents diagram rendering. Verify its version and output in your terminal. To generate a diagram asset for other documents, use the official Mermaid CLI workflow. Displaying an image inside a terminal depends on the terminal's capabilities.

If you want the whole document with diagrams rather than individual image files, save the Markdown and open it in mdview.io. Use the Mermaid terminal guide when your goal is SVG or PNG generation.

A Practical Local Workflow

On Windows 11, mdview Desktop is another option for the rendered-reading step: edit with your terminal tool, save, and read the local file in a separate offline viewer. It reloads after changes in Pro. Keep the terminal for source inspection and remote hosts.

Use a short source-to-render loop instead of expecting one program to solve every stage.

  1. Inspect the file with less README.md.
  2. Edit it in your normal terminal editor.
  3. Check the diff with git diff -- README.md.
  4. Render the document before sharing it.
  5. Verify diagrams, tables, links, images, and math.

If you only need to read the formatted file, follow the steps in How to Open an MD File Online. If you want to launch a browser preview from the terminal, mdv open README.md opens a local preview without uploading the file. The mdview CLI guide shows how to install it and use it to verify Mermaid, share a document, or export a PDF.

Local Files, Privacy, and Relative Assets

Opening a file in a terminal keeps it on your machine. A browser workflow may also process files locally, or it may upload them; check the product's behavior before using confidential material.

Relative images and links deserve a separate check. A source such as ![Diagram](./images/system.png) depends on the Markdown file's location. Moving only the .md file breaks that relationship. A terminal viewer may not show the image at all, while a browser preview may expose the missing path immediately. See how local Markdown files handle images and relative links for portable alternatives.

Which Method Should You Choose?

Use cat or less when you want speed, exact source, searching, piping, or remote-server access. Use a terminal Markdown reader when most documents are prose and code and you want a more comfortable reading experience without leaving the shell. Use a browser renderer when the file contains Mermaid, LaTeX, images, complex tables, or anything you intend to print or share.

The terminal remains the best place to work with the source. It does not have to be the final place you judge the rendered document.