BYTETOOLS

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.

No API key requiredCORS enabledHTTPSFree tier

Endpoint tested and returned HTTP 200 on 2026-08-20

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 2026-08-20, 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
curl 'https://cloudflare-dns.com/dns-query?name=example.com&type=A' \
  -H 'Accept: application/dns-json'
JavaScript (fetch)
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);
Python (requests)
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())
Response — HTTP 200
{
  "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

ParameterTypeRequiredDescription
namestringRequiredDomain name to resolve. example.com
typestringOptionalRecord type: A, AAAA, MX, TXT, NS and others. A
AcceptheaderRequiredMust be application/dns-json for JSON output. application/dns-json
dobooleanOptionalInclude 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

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 2026-08-20; always check the official documentation before relying on this API in production, as terms and limits can change.