HTML Attribute Replacer

Find and replace class, id, href, src, and other HTML attribute values in batches.

HTML Attribute Replacer

What is an HTML attribute replace tool?

An HTML attribute replace tool finds attribute values by name and updates multiple class, id, src, href, data-* or custom attributes at once. It supports exact value, contains, and regular-expression matching, with case sensitivity and first-match-per-tag options. It is useful for renaming CSS classes, changing asset paths, updating component markup, and maintaining templates.

How to replace HTML attributes

  1. Paste HTML and enter the target attribute name, such as class, src, or data-theme.
  2. Enter the find and replacement values, then choose exact, contains, or regular expression mode. Regex is useful for numbered values or changing suffixes.
  3. Click Replace attributes, review the replacement count and output, then copy it or download attribute-replaced.html.

Use cases for attribute replacement

  • Rename CSS classes

    Target class and use contains matching to change an old prefix to a new one across the markup.

  • Switch asset paths

    Target src or href and use exact or contains matching to migrate image, script, style, and link addresses.

  • Update data attributes

    Update custom attributes such as data-theme or data-id while keeping the tag and text structure intact.

  • Protect raw content

    pre, textarea, style, and script contents are temporarily protected so strings or examples inside them are not mistaken for attributes.

HTML attribute replacement FAQ

Will it replace tag text or script content?

No. It processes only valued attributes in opening HTML tags and protects pre, textarea, style, and script contents. Text nodes, closing tags, and raw blocks are left unchanged.

Is regular-expression replacement safe?

The regular expression applies only to the target attribute value, but a broad or incorrect expression can still replace too much. Test a small snippet first and review the replacement count before publishing.

Is source uploaded to a server?

Replacement runs in the current browser, and the tool does not actively upload source to generate output. Follow your security policy for sensitive templates and review external resources you add.

Recommended utilities

You may also need these file utilities