Skip to main content
AllDevToolsHub
Back to all patterns

Data URL (data:)

Web & Network

Matches a data: URL with MIME type, optional parameters, optional base64 flag, and payload.

/^data:[a-zA-Z0-9!#$&\-^_+.]+/[a-zA-Z0-9!#$&\-^_+.]+(;[a-zA-Z0-9-]+=[a-zA-Z0-9-]+)*(;base64)?,.+$/

How it works

RFC 2397 data URLs encode inline content. Used for tiny images, SVG, fonts. Watch the size, anything over a few KB belongs in a regular resource (see the base64 article).

Test Cases

Should Match

  • data:image/png;base64,iVBORw0KGgo=
  • data:text/plain,Hello%20World
  • data:image/svg+xml;charset=utf-8,<svg/>

Should NOT Match

  • data:,empty-mime-not-allowed-here
  • https://example.com

Quick Summary

Matches RFC 2397 data: URLs with explicit MIME and payload.