Cloudflare DNS-over-HTTPS API
Free Cloudflare 1.1.1.1 DNS-over-HTTPS API with no key: resolve any record type as JSON with a documented no-logging privacy policy. Tested example.
Endpoint tested and returned HTTP 200 on 20 Aug 2026
What is the Cloudflare DNS-over-HTTPS API?
Cloudflare's 1.1.1.1 DNS-over-HTTPS API is a free, key-free resolver that answers DNS queries as JSON, with a published privacy policy committing to not logging querying IP addresses.
Functionally this is very close to Google's DoH resolver, and the response format is deliberately compatible — both implement the same JSON DoH convention, so code works against either.
The difference is policy rather than protocol. Cloudflare publishes an audited commitment not to log querying IP addresses and not to sell query data, which matters if you are proxying user lookups. One implementation detail: it requires `Accept: application/dns-json` for the JSON format.
Quick facts
- Base URL
https://cloudflare-dns.com/dns-query- Authentication
- No API key. The header `Accept: application/dns-json` is required for JSON responses.
- Rate limit
- No published hard limit for reasonable use.
- Pricing
- Free.
- CORS
- Enabled — callable directly from browser JavaScript
- Official docs
- Read the docs
How to use the Cloudflare DNS-over-HTTPS API
Every request below was executed against the live API on 20 Aug 2026, and the response shown is the real body it returned — not an illustration.
1. Resolve a DNS record over HTTPS
GET https://cloudflare-dns.com/dns-query?name=example.com&type=A
curl 'https://cloudflare-dns.com/dns-query?name=example.com&type=A' \
-H 'Accept: application/dns-json'const res = await fetch("https://cloudflare-dns.com/dns-query?name=example.com&type=A", {
headers: {
"Accept": "application/dns-json",
},
});
if (!res.ok) throw new Error(`Request failed: ${res.status}`);
const data = await res.json();
console.log(data);import requests
headers = {
"Accept": "application/dns-json",
}
res = requests.get("https://cloudflare-dns.com/dns-query?name=example.com&type=A", headers=headers, timeout=20)
res.raise_for_status()
print(res.json()){
"Status": 0,
"TC": false,
"RD": true,
"RA": true,
"AD": false,
"CD": false,
"Question": [
{
"name": "example.com",
"type": 1
}
],
"Answer": [
{
"name": "example.com",
"type": 1,
"TTL": 114,
"data": "104.20.23.154"
},
{
"name": "example.com",
"type": 1,
"TTL": 114,
"data": "172.66.147.243"
}
]
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Required | Domain name to resolve. example.com |
type | string | Optional | Record type: A, AAAA, MX, TXT, NS and others. A |
Accept | header | Required | Must be application/dns-json for JSON output. application/dns-json |
do | boolean | Optional | Include DNSSEC records. true |
Response fields
Statusinteger- DNS response code — 0 is NOERROR.
ADboolean- DNSSEC validation result.
Questionarray- The query that was asked.
Answerarray- Resource records with name, type, TTL and data.
TC / RD / RAboolean- Truncated, recursion desired and recursion available flags.
What you can build with the Cloudflare DNS-over-HTTPS API
- Build privacy-conscious DNS tooling
- Resolve DNS from client-side JavaScript
- Cross-check answers against another resolver
- Verify DNS propagation from a different vantage point
Common errors and how to fix them
Binary response instead of JSON
The Accept header was missing.
Fix: Send `Accept: application/dns-json` — without it you get DNS wire format, which looks like binary garbage.
Status: 2 (SERVFAIL)
Upstream resolution failed, often a DNSSEC problem.
Fix: Retry, or query with cd=true to bypass DNSSEC checking and see whether that is the cause.
Different answer from another resolver
DNS answers can vary by geography and caching.
Fix: That is expected; compare TTLs and query several resolvers when diagnosing.
Cloudflare DNS-over-HTTPS API — frequently asked questions
Is Cloudflare's DNS API free?
Yes, free with no API key. It runs on the 1.1.1.1 public resolver.
Why am I getting binary data instead of JSON?
The `Accept: application/dns-json` header is required. Without it the endpoint returns DNS wire format, which is binary.
How does it differ from Google's DNS API?
The JSON format is essentially compatible, so code works against either. The difference is policy — Cloudflare publishes an audited commitment not to log querying IP addresses.
Can I use it from a browser?
Yes, that is one of its main uses. Browsers cannot resolve DNS directly, so a DoH endpoint makes client-side DNS tooling possible.
Tools that pair with this API
Alternatives to Cloudflare DNS-over-HTTPS API
If Cloudflare DNS-over-HTTPS does not fit, these security & auth apis cover similar ground. Every one was called before publishing, and each links to its own reference page with a working curl command and the response it returned.
| API | What it does | Auth | CORS | Last verified |
|---|---|---|---|---|
| Pwned Passwords | Free Have I Been Pwned password API with no key. Check if a password appears in known breaches using k-anonymity — the password never leaves your server. Tested. | No key | Yes | 19 Aug 2026 |
| Have I Been Pwned Breaches | Free Have I Been Pwned breach list API with no key: every catalogued data breach with date, affected accounts and compromised data types. Tested curl example. | No key | Yes | 19 Aug 2026 |
| NVD CVE | Free NIST National Vulnerability Database API: search CVEs by id, keyword, severity, CVSS score and date with full descriptions and references. Tested example. | No key | Yes | 19 Aug 2026 |
| CIRCL CVE Search | Free CIRCL CVE Search API with no key: query vulnerabilities by id, vendor or product, and pull the latest published CVEs. CORS enabled. Tested example. | No key | Yes | 19 Aug 2026 |
| CVE Program (CVE Services) | Free CVE Program API with no key: fetch the authoritative CVE Record for any CVE ID in JSON 5.1 format, straight from the CVE Services registry. Tested example included. | No key | Yes | 21 Aug 2026 |
| Disify | Free disposable email checker API with no key: detect temporary and throwaway email domains, validate format and check DNS. CORS enabled. Tested example. | No key | Yes | 19 Aug 2026 |
Cloudflare DNS-over-HTTPS is an independent third-party service and is not affiliated with ByteTools or ByteVancer. Details on this page were verified on 20 Aug 2026; always check the official documentation before relying on this API in production, as terms and limits can change.