Markdown link syntax and conversion between inline and reference links

How Markdown link syntax works, how inline and reference links differ, what converting between them changes, and when the result stays readable and usable.

Markdown gives you two main ways to write a hyperlink: inline links, where the destination sits right next to the link text, and reference links, where the link text points to a label defined elsewhere in the document. Tools that convert between the two styles change how the source looks. They are not meant to change what the reader sees. This review explains the syntax, what a conversion changes, and when the converted result stays usable after copying or sharing.

A note on the examples: this article contains no real web addresses. Wherever a link destination would go, the placeholder ADDRESS stands in for it. In your own documents, that position holds a URL or a relative path.

Short answer: is converting link styles suitable for your use?

For most Markdown documents, converting between inline and reference links is a low-risk change. The rendered output should be identical either way, so readers of the rendered page see no difference. The main benefit appears in the source: reference links keep long destinations out of the prose, which makes paragraphs easier to read and edit. The main tradeoff is portability. A reference link only works while its definition stays in the same document. If you copy part of a document, the definitions can be left behind, and the links break.

Plain text, or a plain inline link, is the better choice in three situations: when people will read the raw source and need to see each destination where it is used, when the content will be pasted in pieces into other documents or messages, and when the destination will not render Markdown at all.

Markdown link syntax: the core forms

The forms below follow the CommonMark specification, which many Markdown implementations use as a baseline. Individual platforms may add extensions or differ on edge cases, so check your renderer's documentation for behavior outside these basics.

Inline links

An inline link puts the link text in square brackets. The destination follows immediately in parentheses, with no space in between. You can add an optional title after the destination, enclosed in double quotes, single quotes, or parentheses. Many renderers display the title as a tooltip.

Read the [project guide](ADDRESS) before you start.

Read the [project guide](ADDRESS "Optional title") before you start.

If a destination contains spaces, you can wrap it in angle brackets inside the parentheses. Parentheses inside a destination are allowed if they are balanced; otherwise, escape them with a backslash.

Reference links and link reference definitions

A reference link replaces the parenthesized destination with a label. A separate line, called a link reference definition, maps that label to the destination and an optional title. The definition can appear anywhere in the document, and it produces no visible output of its own.

Read the [project guide][guide] before you start.

[guide]: ADDRESS "Optional title"

CommonMark recognizes three reference forms:

  • Full: [link text][label], where the label differs from the visible text
  • Collapsed: [link text][], where the link text doubles as the label
  • Shortcut: [link text], where the link text is the label and nothing follows
See the [full form][setup], the [collapsed form][], or the [shortcut form].

[setup]: ADDRESS
[collapsed form]: ADDRESS
[shortcut form]: ADDRESS

Label matching in CommonMark ignores case and treats runs of internal whitespace as a single space, so [Guide] and [guide] refer to the same definition. If two definitions share a label, the first one wins. In the full form, no whitespace is allowed between the two bracketed parts.

Autolinks and images

A destination wrapped in angle brackets, such as <ADDRESS> with a real absolute URL in place of the placeholder, becomes an autolink: the address itself serves as the link text. Some platforms also turn bare URLs into links automatically. That behavior is an extension and is not part of core CommonMark. Images use the same inline and reference syntax with an exclamation mark in front, so a link-style converter may also rewrite image references. Check whether yours does.

![Diagram of the build steps](ADDRESS)

![Diagram of the build steps][diagram]

[diagram]: ADDRESS

Inline vs reference links at a glance

Aspect | Inline link | Reference link
Where the destination lives | Next to the link text | In a definition line elsewhere in the document
Readability of raw source | Long destinations can interrupt sentences | Prose stays clean; destinations are grouped
Reusing one destination | Must be repeated each time | One definition serves every use of the label
Copying a fragment of source | Self-contained | Breaks if the definition is not copied too
Rendered output | Standard link | The same standard link
Maintenance | Edit each occurrence | Edit the single definition

What converting between link styles actually changes

This is a change to Markdown source formatting. It is not a character-level transformation. Your text is not reversed, mirrored, or swapped for look-alike Unicode characters. A converter rearranges where the destination and title are stored in the source file. Once the file is rendered, the reader should see the same link text, pointing to the same destination, with the same title.

When converting inline links to reference links, a tool typically does the following:

  • Replaces each parenthesized destination with a label, which may be a number or a word taken from the link text
  • Adds definition lines, usually at the end of the document or after the paragraph that uses them
  • May merge repeated destinations under a single label

When converting reference links to inline links, it moves each definition's destination and title into the parentheses after the link text and removes the definition lines that are no longer used.

Some details may change even in a correct conversion: label names, label numbering, where definitions are placed, and which quote style wraps the title. None of these affect the rendered page, but they do show up as edits in version control diffs. Converting back and forth will not necessarily restore the original source byte for byte.

Edge cases worth checking after a conversion

Converters that use a full Markdown parser should handle the following cases the way the specification does. Tools that rely on simple pattern matching may not. No specific converter was tested for this article, so treat this list as a checklist, not as a description of any particular tool's behavior.

  • Bracket-like text inside code spans or code blocks, which is not a link and should be left untouched
  • Destinations that contain parentheses, spaces, or angle brackets
  • Link text that contains nested brackets, emphasis, or inline code
  • Duplicate labels, where only the first definition is used
  • Labels that differ only in letter case, which match each other
  • Images, which use the same syntax and may or may not be in scope
  • Definitions placed inside block quotes or list items
  • Existing definitions that no link uses

A practical check is to render the document before and after conversion and compare the output. Your renderer should produce the same HTML for both versions.

Will links stay readable and usable after copying or sharing?

Copying Markdown source

Inline links are self-contained: copy the sentence and the link comes with it. A reference link copied without its definition is no longer a link. In CommonMark, a bracketed label with no matching definition renders as literal text, so the reader sees the brackets and the destination is lost. If people often copy fragments of your documents, for example code snippets, changelog entries, or answers pasted into chat, inline links are the safer choice. The same goes for any tool that splits documents into separate pieces.

Copying rendered output

Once a document is rendered, inline and reference links look the same, so the source style has no effect on copying. Whether the link survives a paste depends on the destination application. Rich-text editors may keep the hyperlink. Plain-text fields usually keep only the link text and drop the destination. Behavior varies by application and was not tested here, so check the destinations you rely on. If the address needs to survive a paste into plain text, write it out in the text itself.

Readers of the raw source

Some audiences read Markdown without rendering it, for example in a terminal, a plain-text email, or a code review view. For them, reference links keep sentences readable but make them look further down to find the destination. Inline links show the destination in place, but long URLs can make paragraphs hard to follow. Descriptive labels, such as [install-guide] instead of [3], help raw-source readers connect a link to its definition.

Accessibility and search

Assistive technology works with the rendered link, not the Markdown source, so the choice between inline and reference style should not affect it. What matters is the link text. Screen reader users often navigate by jumping from link to link, so text that names the destination, such as "project guide", works better than "click here" or a bare URL. The same descriptive text gives search engines a clearer signal about the linked page. No assistive technology or search engine was tested for this article. These points reflect general accessibility guidance on link purpose and do not describe any specific product's behavior.

Compatibility across platforms

Inline links, full reference links, and link reference definitions are part of core Markdown and are widely supported. Collapsed and shortcut forms are defined in CommonMark, but older or nonstandard parsers may treat edge cases differently. Bare-URL autolinking depends on the platform. Before you convert a large set of documents, render a sample on each platform that will display them. A result that looks correct on one platform does not guarantee the same result on others.

Choosing a style

  • Choose inline links for short documents, content that will be copied in fragments, and links used only once
  • Choose reference links for long prose, documents that reuse the same destinations, and files that are mostly edited as raw source
  • Use descriptive labels instead of numbers if people will read the source
  • Keep definitions in one predictable place, such as the end of the document or the end of each section
  • Render before and after converting, and compare the output
  • Write the destination out as plain text when it must survive printing or pasting into plain-text fields

Evidence and gaps

The syntax described here follows the CommonMark specification and general, verifiable Markdown behavior. This article does not evaluate any specific conversion tool, editor, or publishing platform. It contains no measurements, test results, or claims about how particular applications handle pasted links or how particular screen readers announce them. Before relying on a conversion workflow, check your renderer's documentation and test it on the platforms your readers actually use.