coderef

DOMParserBaseline · Widely available

The DOMParser API parses XML or HTML source code from a string into a DOM Document.

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Mar 21, 2016. Widely available since Sep 21, 2018.

Browser support

DesktopChrome
1–30Not supported
31+Supportedsince Nov 12, 2013
Current: 155
Edge
12+Supportedsince Jul 29, 2015
Current: 154
Firefox
1–11Not supported
12+Supportedsince Apr 24, 2012
Current: 157
Safari
1–9Not supported
9.1+Supportedsince Mar 21, 2016
Current: 27
MobileChrome Android
18–30Not supported
31+Supportedsince Nov 14, 2013
Current: 155
Firefox Android
4–10Not supported
14+Supportedsince Jun 26, 2012
Current: 157
Safari iOS
1–9Not supported
9.3+Supportedsince Mar 21, 2016
Current: 27

How to use

This feature is Baseline widely available — use it freely, no fallback needed.

Example

Full syntax and examples are on MDN: DOMParser.

Feature detection

JS · check before using
if ("DOMParser" in globalThis) {
  // DOMParser is available
} else {
  // load a polyfill or use a fallback
}

Sub-features

Support for each part of the feature (5). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
DOMParser11211.31841
DOMParser.DOMParser11211.31841
DOMParser.parseFromString11211.31841
DOMParser.parseFromString.html3112129.131149.3
DOMParser.parseFromString.xml11211.31841