HTML DOM inputEncoding Property

Last Updated : 10 Aug, 2026

The inputEncoding property returns the character encoding used for parsing the document. This property doesn't have any default value. 

Syntax

document.inputEncoding

Parameters: The HTML DOM inputEncoding property does not require any parameter.

Return Value: The HTML DOM inputEncoding property returns a String which represents the document's character encoding.

Example: 

html
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>

<head>
    <title>
        HTML | DOM inputEncoding Property
    </title>

</head>

<body>
    <p>
        Click the button to check the
        encoding of this document
    </p>
<!--Driver Code Ends-->

    <button onclick="geek()">
        Alert document's encoding
    </button>
    <script>
        function geek() {
            var docEncoding = document.inputEncoding;
            alert(docEncoding);
        }
    </script>

<!--Driver Code Starts-->
</body>
</html>
<!--Driver Code Ends-->
  • The code uses the document.inputEncoding property to retrieve the character encoding of the current HTML document and displays it using an alert() message when the button is clicked.
  • The geek() function is triggered by the button's onclick event, which reads the document encoding (such as UTF-8) and shows the result to the user.
Comment