Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Guidelines for escaping strings and handling user-controlled data in DevTools to prevent layout bleed-through, XSS, and security issues.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-06 | ✗→✓ | ▲ Improved | 10% | 0% |
| case-01 | ✗→✓ | ▲ Improved | -40% | 0% |
| case-02 | ✗→✓ | ▲ Improved | -49% | 0% |
| case-03 | ✗→✓ | ▲ Improved | -25% | 0% |
| case-04 | ✗→✓ | ▲ Improved | -54% | 0% |
When displaying inspected data, user-controlled strings, or untrusted input in the DevTools UI (e.g., console messages, object properties, DOM tree nodes, or UI titles/descriptions), you must ensure they are properly escaped to prevent layout bleed-through (such as Right-to-Left leaks) or security vulnerabilities.
DevTools provides two primary Unicode escaping functions in Platform.StringUtilities:
escapeUnicodeAsText)Use Platform.StringUtilities.escapeUnicodeAsText(content) when rendering values that developers need to inspect (e.g. string values inside the Console or the Object properties view) where hidden, invisible, or formatting characters should be made explicitly visible.
\u202E, \u200B).typescript const text = Platform.StringUtilities.escapeUnicodeAsText(JSON.stringify(description));
safeEscapeUnicode)Use Platform.StringUtilities.safeEscapeUnicode(content) when rendering content inside templates or HTML markup where you want safe layout-critical zero-width formatting characters to function normally for word wrapping or rendering layout, but want to escape dangerous layout-disrupting characters (like bidi overrides).
\u202E), but leaves safe formatting characters untouched:\u200B)\u200C)\u200D)Used automatically by the global Lit template wrapper.
DevTools wraps Lit's default html function inside front_end/ui/lit/strip-whitespace.ts (re-exported via ui/lit/lit.js). This wrapper automatically intercepts and escapes standard string values using Platform.StringUtilities.safeEscapeUnicode(val) at runtime.
html<span>${myString}</span>).ifDefined, live, repeat, classMap, etc.) are automatically traversed, and any string arguments inside their values array are escaped recursively.Because the wrapper automatically processes directive arguments, you do not need to manually escape strings passed to standard Lit directives. They will be handled safely at runtime.
typescripttitle=${ifDefined(tooLong ? undefined : description)} // Automatically escaped!
Any manual assignments that bypass Lit entirely (e.g., setting element.textContent, element.title, or constructing DOM elements imperatively) will also bypass the Lit wrapper.
escapeUnicodeAsText if you want hidden characters to display as text (e.g., showing \\u202E).safeEscapeUnicode if you want zero-width spaces to function but other dangerous characters to be escaped.typescriptnameElement.textContent = Platform.StringUtilities.escapeUnicodeAsText(name);
Other measured skills in the registry, with their headline benchmark lift.