Firefox Tomorrow

web api instance method

URL: toJSON() method

View on MDN ↗

Available in workers

The toJSON() method of the URL interface returns a string containing a serialized version of the URL, although in practice it seems to have the same effect as toString().

Syntax

toJSON()

Parameters

None.

Return value

A string.

Examples

const url = new URL(
  "https://developer.mozilla.org/en-US/docs/Web/API/URL/toString",
);
url.toJSON(); // should return the URL as a string

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also