On this page
A URL containing parentheses can make a Markdown link end earlier than you expect. The safest fix depends on your Markdown renderer and whether you can change the URL: wrap the destination in angle brackets, escape the parentheses for Markdown, or use percent-encoded characters if the destination accepts them.
The examples below target CommonMark-style Markdown. Renderer behavior can differ, especially in older or simplified parsers; the examples have not been executed against a renderer for this article. Check them in the renderer your documentation site uses.
Key Takeaways
- An unescaped
)can close an inline Markdown link before the intended URL ends. - Angle brackets make the destination boundary explicit:
[text](<URL>). - Backslash escapes change how Markdown reads the source; percent encoding changes the URL sent to the destination.
- Test the rendered link and its actual destination in your documentation environment.
Why a markdown link URL with parentheses can break
An inline link normally has this form:
[Link text](destination)
Consider a destination whose filename contains a closing parenthesis:
https://example.com/docs/report)final.md
Writing it directly can close the Markdown link at the first ):
[Report](https://example.com/docs/report)final.md)
In CommonMark, the intended result is not a link to the full URL: the link destination ends at report, and final.md) remains outside the link.
Balanced parentheses are a subtler case. A CommonMark renderer can handle a simple balanced pair in a destination, so this can work:
[Draft guide](https://example.com/docs/guide_(draft).md)
Do not assume every renderer handles nested or balanced parentheses identically. If documentation is rendered in more than one place, use a clearer form and check each renderer.
Advertisement
Three ways to write the link
1. Wrap the destination in angle brackets
Place < and > inside the link's outer parentheses:
[Report](<https://example.com/docs/report)final.md>)
The angle brackets delimit the destination, so the closing parenthesis in the URL does not end the Markdown link. This is often the most readable choice for a URL with several parentheses.
The angle-bracket form has its own syntax rules: it is not a way to put literal newlines or unescaped angle brackets in a destination. If a URL contains spaces or other characters that need encoding, use a properly encoded URL.
2. Escape parentheses in the Markdown source
A backslash tells a CommonMark-style parser to treat the following punctuation as part of the destination rather than as link syntax:
[Report](https://example.com/docs/report\)final.md)
[Draft guide](https://example.com/docs/guide_\(draft\).md)
The backslashes are Markdown escapes; they are not intended to be part of the resulting URL. This approach is useful when you want to keep the conventional inline-link form, but links with many escapes can be harder to review.
3. Percent-encode the parentheses
You can represent ( as %28 and ) as %29 in a URL:
[Report](https://example.com/docs/report%29final.md)
[Draft guide](https://example.com/docs/guide_%28draft%29.md)
Unlike a Markdown backslash escape, percent encoding is part of the URL representation. Do not assume the encoded and unencoded URLs reach the same resource. Parentheses are reserved URI characters, and servers, proxies, or application routers may handle encoded characters differently. Use the encoded form only after checking the actual destination.
Advertisement
Check a link in your documentation repository
- Identify the intended URL. Copy it from the destination's authoritative location rather than guessing its spelling. For a local documentation page, check the relative path as well as any fragment.
- Choose a representation. Try angle brackets for readability, Markdown escapes when appropriate, or percent encoding when the destination supports it.
- Preview using the project's renderer. Use the repository's normal preview or documentation build, not just a generic Markdown editor. If the same file is rendered on a repository host and a separate documentation site, check both.
- Inspect the rendered link. Confirm that the link text is correct and that its destination includes the entire path, query, and fragment. A browser's link inspector can help; displayed URLs may be normalized by the browser.
- Open the link and verify the result. Check that it reaches the intended page or file, not merely a successful response or a redirect to an unrelated page. For private links, test with the appropriate access.
- Run the repository's existing build and link checks. Investigate failures rather than assuming a successful Markdown preview proves the destination exists. Automated checks may not have access to authenticated or internal pages.
Common Mistakes
- Escaping for the wrong layer.
\)is Markdown source syntax;%29is URL encoding. They are not interchangeable fixes in every system. - Encoding an entire URL indiscriminately. Encoding structural characters such as
:,/,?, or#can change how the URL is interpreted. Encode the relevant components or characters deliberately. - Assuming balanced parentheses guarantee portability. A link that works in one renderer may fail in another, particularly with nesting or unusual destinations.
- Checking only the visible text. A link can look correct while its destination is truncated or points to the wrong resource.
- Double-encoding an existing escape. Turning an existing
%29into%2529changes the URL and may change the target.
Best Practices
Prefer the form that is easiest for your team to review and that works in every renderer the repository supports. When the original URL contains parentheses, angle brackets preserve that URL in a readable Markdown source. If you use an encoded alternative, verify the exact encoded destination rather than assuming it is equivalent.
Include representative links with parentheses in your documentation review or link-checking workflow, especially when changing renderers or build tooling.
Conclusion
For parentheses in Markdown link destinations, start with the angle-bracket form or Markdown escapes. Use percent encoding when the destination accepts it, and verify the rendered link in the documentation environments your readers actually use.
What would your domain sell for?
A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.