Markdown Links: Convert Between Inline and Reference Styles
How to hyperlink in Markdown with inline or reference links, what converting between them changes, and when each style or plain text fits best.
Markdown offers two main ways to write a hyperlink. Inline links put the destination beside the link text. Reference links keep a short label in the prose and define the destination elsewhere in the file. Converting between them changes how the source reads and how it is maintained. In a renderer that follows the CommonMark specification, the rendered link stays the same. This review explains what the conversion changes, where it can break, and which style suits which job.
About the examples: placeholders such as DESTINATION stand in for real addresses. No specific conversion tool was tested for this article. Statements about rendering come from the CommonMark specification's documented behavior, not from measured results in particular apps.
Short answer: is converting link styles right for you?
Converting inline links to reference links suits long documents that you edit as source text. Typical cases are documentation, READMEs, and articles kept in version control. The main benefit is readable prose in the source file. Long addresses no longer interrupt sentences, and one destination can serve several links. The decisive tradeoff is that the link and its destination are no longer in the same place. Any excerpt copied without its definitions loses its links.
Inline links are the safer default for short text that gets copied, quoted, or pasted in pieces, such as comments, chat messages, issue replies, and snippets. Use plain text instead of either Markdown style when the destination will not render Markdown. Examples include plain-text email, text messages, and some form fields. There, readers see raw brackets and labels, so writing the link text followed by the bare address is clearer.
How to hyperlink in Markdown: the forms you can choose from
An inline link places the link text in square brackets, followed immediately by the destination in parentheses. An optional title in quotes can follow the destination.
Read the [installation guide](DESTINATION "Optional title") before you begin.
A full reference link places a label in a second pair of brackets. A link reference definition, on its own line elsewhere in the document, maps that label to the destination.
Read the [installation guide][install] before you begin.
[install]: DESTINATION "Optional title"
CommonMark also defines two shorter reference forms. Both use the link text itself as the label. The collapsed form adds empty brackets after the link text. The shortcut form uses only the bracketed text.
Collapsed: see the [installation guide][] first.
Shortcut: see the [installation guide] first.
[installation guide]: DESTINATION
An autolink wraps an absolute address in angle brackets and shows the address itself as the link text. Images use the same inline and reference syntax with an exclamation mark in front, so a link-style converter may treat them the same way.
| Form | Source pattern | Destination location | Best fit |
| Inline | text | Next to the text | Short content, snippets, anything copied in pieces |
| Full reference | [text][label] plus a definition line | Definition line anywhere in the file | Long documents, reused or very long destinations |
| Collapsed reference | [text][] plus a definition line | Definition line, label equals the text | Reused links whose text never varies |
| Shortcut reference | [text] plus a definition line | Definition line, label equals the text | Minimal markup where the renderer supports it |
| Autolink | <absolute address> | Shown as the text itself | Cases where the address itself should be visible |
What the conversion actually changes
Converting link styles rewrites the stored characters of the Markdown source. It is not a visual effect. That is different from transformations that only change appearance, such as CSS styling, mirrored display, or Unicode look-alike "fonts". Here, "convert" means the destination text moves from one place in the file to another, and labels are added or removed. Nothing about the characters in the link text should change.
Under CommonMark, an inline link and an equivalent reference link render to the same link element, with the same text, destination, and title. The reader of the rendered page should see no difference. The differences show up in the source file and in how the document behaves when it is edited, split, or processed.
- Label matching is case-insensitive, and CommonMark normalizes runs of internal whitespace, so [Install] and [install] refer to the same definition.
- If two definitions share a label, the first one in the document is used and later duplicates are ignored. A careless merge can therefore point links at the wrong destination without any visible error.
- If a reference has no matching definition, it is not a link. The brackets and text render literally.
- Definition lines themselves do not appear in the rendered output.
- A definition can appear before or after the links that use it. Placing all definitions at the end of the file or section is a convention, not a requirement.
Where conversions can go wrong
A correct conversion should produce identical rendered output. Several details commonly trip up manual edits and simple search-and-replace scripts. These are risks to check for, not observed failures of any particular tool.
- Code spans and code blocks: bracket-and-parenthesis text inside code is literal. It must not be converted, or code examples will be altered.
- Destinations containing spaces or unbalanced parentheses: inline links need angle brackets or escaping for these. A converter that copies the destination verbatim in either direction can produce a broken link.
- Titles with quotation marks: a title must be delimited so its own quotes do not end it early.
- Nested brackets or escaped characters in link text: naive pattern matching can cut the text at the wrong bracket.
- Label collisions: generated labels, such as numbers or slugified text, can clash with labels already in the file. The first-definition rule then silently changes a destination.
- Label churn: tools that renumber labels on each run can create large, noisy diffs in version control even when no destination changed.
- Flavor differences: some renderers do not follow CommonMark exactly, especially for shortcut references, so check the converted file in the renderer you actually publish with.
A practical check after any conversion is to render the document before and after and compare the resulting link targets. If your workflow allows it, comparing the generated HTML directly is more reliable than inspecting the page by eye.
Will links stay usable after copying or sharing?
The biggest practical difference appears when source text is copied. An inline link carries its destination with it, so a pasted sentence still works wherever Markdown is rendered. A reference link copied without its definition line becomes literal bracketed text in the new location. This matters for anyone who quotes paragraphs into issues, chat, or other documents, and for tools that split one file into fragments.
Copying from the rendered page is a separate question. What gets copied depends on the browser, app, and paste target, not on which Markdown style produced the link. Some destinations keep the link and others keep only the text. No destinations were tested for this review, so check yours before relying on links surviving a paste.
Both styles produce the same rendered link, so screen readers and other assistive technology should handle them identically. What matters for accessibility is the link text. Descriptive text that makes sense out of context works better than phrases like "click here". Converting styles neither fixes nor causes problems with link text, but a conversion pass is a convenient moment to review it.
Searching and editing the source also behave differently. In a reference-style file, searching for an address finds the definition line, not the sentences that use it. You then search again for the label. On the other hand, updating one definition fixes every link that shares it, which is harder to do safely with many repeated inline destinations.
Choosing between inline links, reference links, and plain text
The choice depends on two questions: whether people mostly read and edit the raw source or the rendered output, and whether the text will be copied in pieces. The comparison below is based on documented syntax behavior. It does not compare outputs from specific conversion tools, which were not tested.
| Criterion | Inline links | Reference links | Plain text with bare address |
| Source readability in long prose | Weaker; long addresses interrupt sentences | Stronger; prose stays uncluttered | Moderate; addresses appear in full |
| Survives partial copy of source | Yes, where Markdown renders | No, unless definitions are copied too | Yes, as readable text |
| Reusing one destination many times | Repetitive; each copy updated separately | One definition, updated once | Repetitive |
| Works where Markdown is not rendered | Shows raw syntax | Shows raw syntax and stray labels | Yes |
| Risk of silent wrong destination | Low | Higher, through label collisions or duplicate definitions | Low |
| Rendered result for readers and assistive technology | Standard link | Same standard link | Depends on whether the destination auto-detects addresses |
Reference links become the better choice as documents grow longer, destinations get longer or repeat, and editing happens mainly in the source. Inline links win when content is short, frequently excerpted, or written in tools that may support only part of Markdown. Plain text wins whenever the destination does not render Markdown at all.
Conversion can be done by hand, with an editor or formatter feature, with a document converter that can output either link style, or with a custom script. For anything beyond a few links, a parser-based approach is generally safer than pattern matching, because it understands code spans, escapes, and nesting. This review cannot say which named tools handle the edge cases above correctly, because none were tested. Run a before-and-after render comparison on a representative file before converting a whole repository.
Gaps in this review
- No conversion tools, editor extensions, or scripts were tested, so no tool is recommended by name and no accuracy claims are made.
- Rendering behavior is described from the CommonMark specification. Platforms using other Markdown flavors may differ, especially for shortcut references and duplicate labels.
- Copy-and-paste behavior from rendered pages was not tested in any browser, app, or assistive technology, and will vary by environment.