This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The Document.characterSet read-only property returns the character encoding of the document that it's currently rendered with.
Note: A "character set" and a "character encoding" are related, but different. Despite the name of this property, it returns the encoding.
A string.
console.log(document.characterSet); // document's character encoding, such as "ISO-8859-1" or "UTF-8"
| Specification |
|---|
| DOM> # ref-for-dom-document-characterset①> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
characterSet |
11charset alias was made read-only in Chrome 45. |
121212 | 1441.5 | ≤12.115charset alias was made read-only in Opera 45. |
333 | 1818charset alias was made read-only in Chrome Android 45. |
4444 | ≤12.114charset alias was made read-only in Opera 45. |
111 | 1.01.0charset alias was made read-only in Samsung Internet 5.0. |
11charset alias was made read-only in WebView 45. |
111 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Document/characterSet