Viewport meta tag generator for responsive web pages
Generate a responsive viewport meta tag without recalling its exact attribute order or punctuation.
Run — free
Choose device-width for the standard mobile-friendly declaration, or enter a positive numeric width for a deliberate fixed viewport, then set the initial scale. The result includes a complete HTML tag ready to copy into a document head, its content value, and normalized settings that are convenient for scripts, templates, tests, and automated build pipelines across projects.
Choose the viewport width deliberately
A viewport declaration tells a mobile browser how the page's layout viewport should relate to the screen. For most responsive sites, device-width is the right setting because it follows the device's CSS-pixel width and lets media queries respond to the available space. This generator also accepts a positive numeric width when a controlled, fixed layout viewport is genuinely required, such as a legacy embedded interface, a reproducible browser fixture, or a compatibility test. Enter the number without a px suffix: 375 is valid, while 375px is not a viewport width value in this declaration. Zero, negative values, empty input, non-finite values, and arbitrary words are rejected instead of being placed into markup that looks plausible but does not express the requested setting. The returned width is normalized, so numeric text such as 375 becomes the stable content fragment width=375. This narrow validation makes the output useful in automation: success means the width is either the exact standard keyword or a positive number, with no hidden spelling correction or browser-dependent guesswork.
Set initial scale and copy the generated tag
The initial scale controls the zoom level when the page first loads. A value of 1 is the conventional choice: one CSS pixel maps to one viewport CSS pixel before the user zooms. The field defaults to 1, but another positive finite number can be supplied for a specific testing or application requirement. The generator validates that setting separately and preserves its numeric meaning in a stable textual form. It then produces a complete tag such as <meta name="viewport" content="width=device-width, initial-scale=1">. Place that tag inside the document's head, ideally once, rather than appending multiple viewport declarations whose interaction may differ between browsers. The response also exposes the content string and normalized width and initial_scale fields. Use meta_tag when writing HTML, content when a framework expects only the content attribute, and the individual fields when asserting configuration in tests. No network request, page inspection, or user-agent detection changes the result; identical input always returns identical output in the browser and through the API.
Understand what the generator does not add
This capability intentionally generates only width and initial-scale. It does not add maximum-scale, minimum-scale, user-scalable, viewport-fit, interactive-widget, or other optional directives, because those settings require product and accessibility decisions rather than automatic defaults. In particular, restricting user zoom can make content harder to use for people who need magnification, so a small tag generator should not silently introduce that behavior. The tool also does not audit an existing page, detect duplicate tags, test responsive breakpoints, or prove that the CSS itself is responsive. It creates deterministic markup from the two supplied settings. After adding the result, inspect the page at narrow and wide sizes, confirm that text remains readable, verify that controls do not overflow, and test zoom on real browsers. For templated projects, keep the generated declaration in the shared head component so each route receives the same policy. Interactive use on this page runs free in the browser; an automated API request costs $0.002. Because the same pure solver serves both paths, a tag tested manually can move into a build script without changing its formatting or validation rules.
What you can do with it
Start a responsive page
Create the standard device-width and initial-scale declaration for a new HTML document or shared layout template.
Build deterministic fixtures
Generate a fixed numeric viewport declaration for browser tests that need an explicit, reproducible layout width.
Normalize configuration output
Turn form or script settings into one stable tag and separate normalized fields for validation and snapshot tests.
FAQ
What width should a responsive website use?
Use device-width in the usual responsive design case. It follows the device's viewport width in CSS pixels.
Can I enter a fixed width?
Yes. Enter a positive number such as 375 without a unit suffix. Zero, negative, non-finite, and nonnumeric values are rejected.
What initial scale should I use?
A value of 1 is the conventional default. Another positive finite number is accepted when your project has a specific requirement.
Does the result disable zoom?
No. The generator does not add user-scalable, maximum-scale, or minimum-scale directives.
Where does the meta tag belong?
Place it once inside the HTML head. Avoid multiple competing viewport declarations in the same document.
How much does the API request cost?
Each successful API request costs $0.002; interactive execution on this page is free in the browser.
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/web/viewport-meta-generate \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"width":"device-width"}'const res = await fetch("https://api.kit.forhosting.com/web/viewport-meta-generate", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"width": "device-width"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/web/viewport-meta-generate",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"width": "device-width"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/web/viewport-meta-generate", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"width":"device-width"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"width":"device-width"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/web/viewport-meta-generate", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"width": "device-width"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "web.viewport_meta_generate",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
timeout_sec | 30 |
max_crawl_pages | 25 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |