User Rating 0.0
Total Usage 0 times
Use {t} as a placeholder for the word
0 (none)1 (all)
Is this tool helpful?

Your feedback helps us improve.

About

Automated link insertion across large HTML documents is error-prone when done manually. Missing a keyword costs referral traffic. Linking inside a <button> or nested <a> breaks accessibility and violates HTML spec. This tool walks every text node in your markup, applies a configurable probability gate (f [0, 1]) to each eligible word, and wraps selections in anchor elements whose href is built from a URL template with a {t} token. It respects element exclusion lists so structural tags remain untouched, and forces links on priority keywords regardless of the random threshold. Leading and trailing punctuation is stripped from the link text and preserved outside the anchor, preventing malformed URLs.

The algorithm performs a depth-first traversal. Words split across inline tags (e.g., B<b>A</b>CON) are not matched as forced words because the text node boundary interrupts the token. This is intentional: partial-node wrapping would corrupt the DOM tree. The tool approximates the behavior of the OutText jQuery plugin but requires zero dependencies. Limitations: the frequency parameter is stochastic, so output varies between runs for the same input. For deterministic results, set frequency to 1 or rely solely on forced words.

random links text to links word linker HTML link generator outtext auto link words text formatting

Formulas

For each text node discovered by the tree walker, words are extracted via whitespace splitting. Each word w is tested against the link-generation rules in priority order:

{
SKIP if ancestor excluded_elementsLINK if strip(w) forced_wordsLINK if rand() < fSKIP otherwise

The href is constructed as:

href = replace(link_template, "{t}", encodeURIComponent(strip(w)))

Where f = frequency (0 f 1), strip(w) removes leading/trailing non-word characters, and rand() returns a uniform random value in [0, 1). The expected number of random links E across N eligible words is:

E = N f

Reference Data

ParameterTypeDefaultDescription
link_templateString#URL pattern. Use {t} as placeholder for the word text.
frequencyFloat0.1Probability each eligible word becomes a link (0 - 1).
excluded_elementsArray["button", "a"]Tag names inside which no links are generated.
forced_wordsArray[]Words that always become links (case-insensitive, exact match).
{t} tokenToken - Replaced with encodeURIComponent(word) in the final href.
Punctuation handlingBehavior - Leading/trailing punctuation stays outside the <a> tag.
Nested tag wordsBehavior - Words split by inner HTML tags are not matched for forced linking.
Exclusion priorityRuleHighestEven forced words inside excluded elements produce no links.
Case sensitivityRuleInsensitiveForced words match regardless of case ("Bacon" = "bacon").
Empty {t}Behavior - If no {t} in template, href is used as-is for every link.
frequency = 0Edge case - No random links. Only forced words generate links.
frequency = 1Edge case - Every eligible word becomes a link.
Script tags in inputSecurity - Parsed via DOMParser; scripts do not execute in output context.
Self-closing tagsBehavior - <br>, <img>, <hr> are preserved; no text nodes inside them.
Whitespace-only nodesBehavior - Skipped. No empty links generated.

Frequently Asked Questions

The frequency parameter is probabilistic. Each eligible word is tested independently against a random threshold. For deterministic results, set frequency to 1 (all words linked) or 0 (only forced words linked). The expected link count equals N × f where N is the eligible word count and f is the frequency.
The exclusion list takes absolute priority. Even if a word matches the forced_words list, it will not be converted to a link if any ancestor element matches the excluded_elements tags. This prevents invalid nesting such as an inside another .
Leading punctuation (e.g., opening quotes, parentheses) and trailing punctuation (e.g., commas, periods, exclamation marks) are detected via regex and placed outside the generated tag as separate text nodes. The href receives only the clean word. For example, "(bacon)" becomes "(" + bacon + ")". This prevents URL corruption.
No. If a word like "BACON" is interrupted by inner tags (e.g., BACON), each text node contains only a fragment ('B', "A", 'CON'). None of these fragments match the forced word "bacon", so no link is generated. This is by design to avoid corrupting the DOM structure.
Yes. Set frequency to 0, populate forced_words with your target keywords, and set link_template to your landing page URL with or without the {t} token. This ensures only your specified terms become links, with no random noise. Remember that excessive internal linking on a single page can trigger search engine spam filters. A reasonable density is below 2-3% of total word count.
The input is parsed via the browser's DOMParser API, which does not execute scripts. However, the generated output is raw HTML intended for your own use. If you paste untrusted third-party HTML, inspect the output before embedding it in a production page. The tool does not strip event handler attributes (onclick, onerror, etc.).