Yoryantra
← Back to Tools

Content-Disposition Header Generator

Generate Content-Disposition headers for file downloads and inline previews. Build attachment and inline headers with safe filenames, UTF-8 filename*, ASCII fallback, and server snippets.

File Details

Response Options

Selected Content-Type

application/pdf

Options

Use attachment for forced downloads and inline when the browser should try to preview the file.

Output

Generated Content-Disposition output will appear here.

Generating Safe File Download Headers

Content-Disposition tells browsers whether a response should be downloaded as a file or displayed inline. It also controls the filename suggested to the user when saving a file.

This Content-Disposition Header Generator builds safe attachment and inline headers with ASCII fallback filenames, UTF-8 filename* support, and practical server snippets.

Using the Content-Disposition Header Generator

  1. Enter the filename you want users to see.
  2. Choose attachment for downloads or inline for browser previews.
  3. Select a content type and filename format.
  4. Review the generated header and warnings.
  5. Copy the header, headers block, or server snippet.

Attachment vs Inline

  • attachment asks the browser to download the response as a file.
  • inline allows the browser to preview the file when it supports that media type.
  • filename is the simpler ASCII filename fallback.
  • filename* is useful for UTF-8 names with spaces or non-English characters.

Example Content-Disposition Header

Content-Disposition: attachment; filename="invoice-june-2026.pdf"; filename*=UTF-8''invoice-june-2026.pdf
Content-Type: application/pdf

Filenames Should Be Treated Carefully

Filenames can contain spaces, quotes, path separators, Unicode characters, or unsafe characters. For API responses, it is safer to sanitize filenames and provide a simple fallback filename.

Never place untrusted user input into response headers without validation and escaping.

Frequently Asked Questions

What does a Content-Disposition header do?

It tells the browser whether to download a response as a file or display it inline, and it can suggest a filename.

Should I use attachment or inline?

Use attachment for forced downloads. Use inline when browser preview is desired, such as PDFs or images.

What is filename*?

filename* allows UTF-8 encoded filenames and is useful for names with spaces or non-English characters.

Should I include Content-Type too?

Yes. Content-Type helps the browser understand the file type and decide whether it can preview it safely.

Is anything uploaded when I generate headers?

No. The header is generated directly in your browser.