Skip to content
m4bwav edited this page Sep 29, 2026 · 2 revisions

markdown-plain-link-replacer finds the bare http:// and https:// links in a markdown text, requests each page, and puts a titled link in place of the address. It is a library for Node 20 and later, Bun and Deno, with a command line tool.

import {replacePlainLinks} from 'markdown-plain-link-replacer';

const markdown = await replacePlainLinks('Source: https://en.wikipedia.org/wiki/Bespin');
console.log(markdown);

With a page titled Bespin - Wikipedia at that address, it prints:

Source: "[Bespin](https://en.wikipedia.org/wiki/Bespin)", *wikipedia.org*

The site name after - is dropped from the title, and the site in italics is the registrable domain. A template changes the shape. The same from the command line:

$ markdown-plain-link-replacer "Source: https://example.com"
Source: "[Example Domain](https://example.com)", *example.com*

Links that are already markdown links, images, autolinks, reference definitions, HTML attributes or code are left as they are, and so is every link whose page fails, times out, is an image or has no title. Nothing else in the text changes.

Pages

  • Getting started: install with npm, pnpm, yarn or Bun, or use it from Deno; ES modules, CommonJS and TypeScript.
  • API reference: replacePlainLinks in its Promise and callback forms, the options, and every error it throws.
  • How links are replaced: which links count, what is requested, how the title and site are read, and templates.
  • Commands: the markdown-plain-link-replacer command, its options and exit codes.
  • Edge cases and errors: why a link can be left unchanged without a word, and what throws.
  • Recipes: converting files and folders, other link shapes, deadlines, and running behind a proxy.
  • Versions and upgrading: the versions on npm and what changed from 1.x, measured against 1.1.16.
  • FAQ: short answers to the questions the other pages answer at length.
  • Development: building and testing the repository.

About these pages

Every example here was run against the published 2.0.0 from npm, on Node 24.18.0 unless a page says otherwise. No example touched the internet: each page it requests was a local copy served under the real host name, through a local proxy. The titles in the outputs are the local copies' titles, and an ordinary page without its own title was served as Page <path>. The script that ran every example and its full output are kept in the repository (ai-docs/notes/2026-09-29-wiki-verify.mjs), so the next release can run them again.

This wiki describes markdown-plain-link-replacer 2.0.0, released on 2026-09-27.

Clone this wiki locally