Checking HTTP Headers

Related links

i18n Checker

Rex Swain's HTTP Viewer

HTTP Header Checker by KeyCDN

This article describes several ways to check the character encoding information sent in the HTTP header of a web document.

It is important to clearly indicate the character encoding (charset) of a document served on the Web. Otherwise, a receiver may not correctly interpret the document. A Web browser, for example, may show random characters instead of readable text. One way of indicating the character encoding of a Web document is to put this information into the charset parameter of the Content-Type header.

In particular, it is important to note that the encoding declared in the HTTP header overrides all in-document encoding declarations in HTML and CSS files.

The i18n Checker

The Internationalization Checker tool, developed by the W3C, checks web pages for various internationalisation issues. It also has an information section that summarises key internationalization-related information about a page, such as character encoding and language declarations, etc. That section tells you whether an encoding declaration is used in the HTTP header, and if so, what is the encoding.

The i18n checker tool is particularly useful, since it also shows you other encoding declarations used in the document, and raises a flag if there are differences.

Use a Web-based service

There are several services that show you all the HTTP headers and the (HTML) source of the document returned from the server after you enter the address of the document you are interested in:

Note: W3C has no relationship to any of these services.

In the HTTP headers, look for the Content-Type header, and in particular for the charset parameter, e.g.

Content-Type: text/html; charset=utf-8

Note: The charset parameter may not be present. This is okay if your document itself indicates its character encoding.

Use the developer tools in a browser

Modern desktop browsers usually contain a set of web developer tools, and they can be used to view HTTP headers of a web document and its related resources. Here's how to do it in major browsers.

Chrome, Edge, Firefox, and Opera

  1. Open DevTools by pressing Control+Shift+I or Command+Option+I (Mac).
  2. Click the Network tab. Right now the Network panel is empty.
  3. Reload the page to log some network activity. Each row represents a resource. The top resource is usually the main HTML document.
  4. Click a resource and open the Headers tab to view the HTTP headers.
  5. In the HTTP headers, look for the Content-Type header, and in particular for the charset parameter.

Safari

  1. First ensure that the Develop menu is enabled: choose Safari > Settings, click Advanced, then select “Show Develop menu in menu bar”.
  2. Show page resoueces by clicking Develop > Show Page Resources.
  3. Press Command+Option+0 to show the details sidebar.
  4. Reload the page to log some network activity.
  5. Click a resource from the left sidebar and the HTTP headers will appear in the right sidebar.
  6. In the HTTP headers, look for the Content-Type header, and in particular for the charset parameter.

Use telnet or another command-line tool

This requires a bit more expertise, but may be easier to automate. Another command line tool may be wget (with a -S or -s option).

By the way

Some servers transcode the Web documents they serve to different character encodings for different clients. This happens for example with some servers in Russia. This requires special care, because your browser, running e.g. on a Mac or on a Windows system, may indicate using a different character encoding than the encoding given to you by a Web-based service or the W3C Markup Validation Service (which are mostly based on UNIX systems).