MDConverter
Universal In-Browser Converter
100% Client-Side Private

How to Write Comments in Markdown

By the MDConverter team · Updated · 2 min read

Quick answer

The most widely supported way to comment in Markdown is an HTML comment: <!-- your note -->. It can span several lines and is hidden from the rendered page on GitHub, GitLab, VS Code and most site generators — but it stays in the generated HTML, so do not use it for secrets. Where HTML is stripped, the [//]: # (note) link-definition trick hides a single line, and Obsidian has its own %% comment %% syntax.

HTML comments (works almost everywhere)

Everything between <!-- and --> is left out of the rendered page.

Markdown
Visible paragraph.

<!-- TODO: add the pricing table before launch -->

<!--
Multi-line comments work too.
None of this appears.
-->

Another visible paragraph.
Result

Visible paragraph.

Another visible paragraph.

Caveat: the comment is still in the HTML source of the page, so anyone who views the source can read it. Remove passwords, internal notes and personal data before publishing.

A reference-link definition that nothing uses is never rendered — and unlike an HTML comment, it does not reach the HTML output at all. Put it on its own line with a blank line above it.

Markdown
Visible text.

[//]: # (This line is a comment and is not rendered.)
[comment]: <> (So is this one.)

More visible text.
Result

Visible text.

More visible text.

Only single lines work, and the comment text cannot contain an unmatched ).

Obsidian comments

Obsidian hides anything between double percent signs in reading view: %% this is a comment %%, inline or across several lines. Other apps show the %% text, so use HTML comments in files you publish elsewhere.

Useful things to put in comments

  • TODO notes and review remarks while drafting
  • Instructions for contributors (<!-- Keep this list alphabetical -->)
  • Separators between two lists that would otherwise merge (an empty <!-- --> between them)
  • Markers that tools read: TOC generators, linters (<!-- markdownlint-disable MD013 -->) and GitHub issue templates all use HTML comments

Comments when converting

Markdown to Word and Markdown to plain text drop HTML comments, so internal notes do not end up in the document you send. Markdown to HTML keeps them as HTML comments — remove them first if the HTML will be published. Markdown to PowerPoint reads <!-- notes: … --> comments as speaker notes.

Comment support by app

AppSupportedNotes
GitHub / GitLabYesHTML comments and the [//]: # trick are hidden.
VS Code, MkDocs, Hugo, JekyllYesHTML comments hidden (but present in built HTML).
ObsidianYes%% … %% and HTML comments are hidden in reading view.
Reddit, Discord, SlackNoComments are shown as text; do not paste notes into messages.

Common mistakes and how to fix them

ProblemFix
The comment appears on the pageCheck the closing --> and that there is no space in <!--. Some chat apps do not support comments at all.
[//]: # comment is visibleIt needs a blank line above it and must start at the beginning of the line.
A private note was publishedHTML comments are in the page source. Delete sensitive notes before publishing rather than commenting them out.

Tools for this

Frequently Asked Questions

Frequently Asked Questions About Comments & hidden text

Comprehensive answers to common technical, formatting, security, and compatibility questions.

They are hidden from the rendered view, not from people who read the source. HTML comments stay in the HTML; the [//]: # trick stays in the .md file. Treat comments as invisible to casual readers, not as private.

Sources

← All Markdown lessons · Markdown cheat sheet