Javascript

Replace All Text on a Web Page with JavaScript

A memo of sample code for replacing all text on a web page with JavaScript. Use case: You want to show friends or clients the design and layout of a web page you coded/created, but if the text is written as is, the site can be identified. When you want to avoid that. How to: Load the following JavaScript in a file, bookmarklet, or developer tools console...

Shou Arisaka
2 min read
Sep 28, 2025

A memo of sample code for replacing all text on a web page with JavaScript.

Use case: You want to show friends or clients the design and layout of a web page you coded/created, but if the text is written as is, the site can be identified. When you want to avoid that.

How to: Load the following JavaScript in a file, bookmarklet, or developer tools console.

var all = document.getElementsByTagName('p');
for (var i = 0; i < all.length; i++) {
    all[i].innerText = all[i].innerText.replace(/./g, "ใ‚");
}
var all = document.getElementsByTagName('a');
for (var i = 0; i < all.length; i++) {
    all[i].innerText = all[i].innerText.replace(/./g, "ใ‚");
}
var all = document.getElementsByTagName('span');
for (var i = 0; i < all.length; i++) {
    all[i].innerText = all[i].innerText.replace(/./g, "ใ‚");
}
var all = document.getElementsByTagName('li');
for (var i = 0; i < all.length; i++) {
    all[i].innerText = all[i].innerText.replace(/./g, "ใ‚");
}
var all = document.getElementsByTagName('h1');
for (var i = 0; i < all.length; i++) {
    all[i].innerText = all[i].innerText.replace(/./g, "ใ‚");
}
var all = document.getElementsByTagName('h2');
for (var i = 0; i < all.length; i++) {
    all[i].innerText = all[i].innerText.replace(/./g, "ใ‚");
}
var all = document.getElementsByTagName('h3');
for (var i = 0; i < all.length; i++) {
    all[i].innerText = all[i].innerText.replace(/./g, "ใ‚");
}
var all = document.getElementsByTagName('h4');
for (var i = 0; i < all.length; i++) {
    all[i].innerText = all[i].innerText.replace(/./g, "ใ‚");
}
var all = document.getElementsByTagName('h5');
for (var i = 0; i < all.length; i++) {
    all[i].innerText = all[i].innerText.replace(/./g, "ใ‚");
}
var all = document.getElementsByTagName('h6');
for (var i = 0; i < all.length; i++) {
    all[i].innerText = all[i].innerText.replace(/./g, "ใ‚");
}

What it does: Replaces every character of every String in all tags that likely contain text, one character at a time.

  • p
  • a
  • span
  • h1-h6
If you mark these tags, you should be ok for the most part.

You might think you could just replace the innerText of the body tag, but doing so seems to also remove CSS, breaking the layout.

document.body.innerText = document.body.innerText.replace(/./g, 'ใ‚');

Share this article

Shou Arisaka Sep 28, 2025

๐Ÿ”— Copy Links