Browser compatibility data provided by MDN Web Docs for cross-browser web development
tessl install tessl/npm-mdn--browser-compat-data@7.1.0Browser Compat Data provides comprehensive, machine-readable browser compatibility information for Web technologies including Web APIs, JavaScript features, CSS properties, HTML elements, and more. This package serves as the authoritative source of compatibility data used by MDN Web Docs, CanIUse, Visual Studio Code, WebStorm and numerous other web development tools.
npm install @mdn/browser-compat-dataimport bcd from '@mdn/browser-compat-data';For modern Node.js with import attributes:
import bcd from '@mdn/browser-compat-data' with { type: 'json' };For legacy Node.js versions:
import bcd from '@mdn/browser-compat-data/forLegacyNode';For CommonJS:
const bcd = require('@mdn/browser-compat-data');Type definitions:
import type { CompatData, SupportStatement, CompatStatement } from '@mdn/browser-compat-data/types';import bcd from '@mdn/browser-compat-data';
import { query, walk } from '@mdn/browser-compat-data';
// Access compatibility data directly
const flexboxSupport = bcd.css.properties.display.__compat.support;
console.log(flexboxSupport.chrome.version_added); // "29"
// Query data using dotted notation
const fetchAPI = query('api.fetch', bcd);
console.log(fetchAPI.__compat.support.chrome.version_added); // "42"
// Walk through all features
for (const { path, compat } of walk(undefined, bcd)) {
if (compat.status.deprecated) {
console.log(`Deprecated feature: ${path}`);
}
}Browser Compat Data is organized around several key components:
Direct access to the complete browser compatibility dataset containing information for all major web technologies.
const bcd: CompatData;
interface CompatData {
__meta: {
version: string;
timestamp: string;
};
api: { [key: string]: Identifier };
browsers: { [key: string]: BrowserStatement };
css: { [key: string]: Identifier };
html: { [key: string]: Identifier };
http: { [key: string]: Identifier };
javascript: { [key: string]: Identifier };
manifests: { [key: string]: Identifier };
mathml: { [key: string]: Identifier };
svg: { [key: string]: Identifier };
webassembly: { [key: string]: Identifier };
webdriver: { [key: string]: Identifier };
webextensions: { [key: string]: Identifier };
}Functions for querying and navigating the compatibility data using dotted path notation and walking algorithms.
function query(path: string, data?: DataType): DataType;
function walk(
entryPoints?: string | string[],
data?: CompatData
): IterableIterator<WalkOutput>;
interface WalkOutput {
path: string;
data: DataType;
compat: CompatStatement;
}Utilities for analyzing browser support information and extracting support details for specific browsers.
function iterSupport(
compat: CompatStatement,
browser: BrowserName
): SimpleSupportStatement[];
type BrowserName =
| "chrome" | "chrome_android" | "edge" | "firefox"
| "firefox_android" | "safari" | "safari_ios"
| "opera" | "opera_android" | "webview_android"
| "samsunginternet_android" | "oculus" | "webview_ios";Complete TypeScript type definitions for all compatibility data structures, statements and utility functions.
interface CompatStatement {
description?: string;
spec_url?: string | string[];
tags?: string[];
support: SupportBlock;
status?: StatusStatement;
source_file?: string;
}
interface SimpleSupportStatement {
version_added: VersionValue;
version_removed?: VersionValue;
prefix?: string;
alternative_name?: string;
flags?: FlagStatement[];
impl_url?: string;
notes?: string | string[];
partial_implementation?: boolean;
}
type VersionValue = string | boolean | null;The main dataset is organized into these technology categories:
api - Web API interfaces and their methods/properties (Fetch API, Web Storage, etc.)css - CSS properties, selectors, at-rules, and functions (flexbox, grid, custom properties, etc.)html - HTML elements, attributes, and global attributes (semantic elements, form controls, etc.)http - HTTP headers, status codes, and methods (CORS headers, caching, etc.)javascript - JavaScript language features and built-in objects (ES6+ features, array methods, etc.)browsers - Browser information including releases, engines, and metadatamanifests - Web App Manifest properties and Progressive Web App featuresmathml - MathML elements and attributes for mathematical notationsvg - SVG elements, attributes, and features for vector graphicswebassembly - WebAssembly instructions, types, and runtime featureswebdriver - WebDriver automation commands and capabilitieswebextensions - Browser extension APIs across different browsersEach category contains hierarchically organized compatibility data with detailed browser support information, standardization status, and implementation notes.