Skip to content

Corrupt Text

A copy-paste glitch & distortion component in pure HTML, CSS & vanilla JS. Zero dependencies, framework-agnostic, MIT-licensed.

Glitch & DistortionHTMLCSSJavaScriptany framework
NUDAUI

Copy into your project

HTML
<!-- Corrupt Text — characters scramble through random glyphs, then
     resolve. The data-text attribute holds the clean final string. -->
<span class="nuda-glitch-corrupt" data-glitch-corrupt="NUDAUI">NUDAUI</span>
CSS
/* ── Corrupt Text ────────────────────────────────────────────
   JS-driven char-swap; CSS only handles the base look. The final,
   resolved text is plain lime monospace at full contrast.
   ──────────────────────────────────────────────────────────── */
.nuda-glitch-corrupt {
  display: inline-block;
  font-family: monospace;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #e4ff54;
  background: #09090b;
  padding: 0.3rem 0.5rem;
  text-shadow: 0 0 12px rgba(228, 255, 84, 0.35);
}
JavaScript
/* ── Corrupt Text — vanilla JS ───────────────────────────────
   Scrambles each character through random glyphs before locking in
   the final text, then pauses and repeats intermittently.
   Reduced-motion: bail out entirely and show the clean text.
   ──────────────────────────────────────────────────────────── */
;(function () {
  var REDUCE = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
  var GLYPHS = "!<>-_\\/[]{}=+*^?#01";

  document.querySelectorAll("[data-glitch-corrupt]").forEach(function (el) {
    var finalText = el.getAttribute("data-glitch-corrupt") || el.textContent;
    el.textContent = finalText;

    /* Respect reduced-motion: leave the clean text in place. */
    if (REDUCE) return;

    var reveal = 4;   /* frames each char stays scrambled */
    var step = 55;    /* ms per frame (keeps swaps < ~18/sec, no strobe) */
    var pause = 1800; /* ms idle between corruption bursts */
    var frame = 0;
    var timer;

    function burst() {
      var out = "";
      for (var i = 0; i < finalText.length; i++) {
        out += i < Math.floor(frame / reveal)
          ? finalText[i]
          : GLYPHS[(Math.random() * GLYPHS.length) | 0];
      }
      el.textContent = out;
      frame++;

      if (frame > finalText.length * reveal + 8) {
        el.textContent = finalText;
        frame = 0;
        timer = setTimeout(burst, pause); /* intermittent restart */
      } else {
        timer = setTimeout(burst, step);
      }
    }

    burst();
  });
})();

How to use Corrupt Text

Paste the HTML where you need it and the CSS into a global stylesheet (or a <style> tag). Every class is prefixed nuda- so it never collides with Tailwind or your own styles. Tweak the CSS custom properties to match your design system.

Works in React, Vue, Svelte, Astro, Next.js, Nuxt, Laravel Blade, Django, Rails — or a single .html file. No npm install, no build step.

More glitch & distortion components

← Browse all NudaUI components