Skip to main content

Convert a Domain List into JSON, SQL IN, CSV, and TypeScript Union Output

Turn a plain list of domain names into a JSON allowlist array, a SQL IN clause, CSV, or a TypeScript union in one step, no hand-quoting each host.

Published By Li Lei
#domains #developer-tools #converter #allowlist

Convert a Domain List into JSON, SQL IN, CSV, and TypeScript Union Output

A list of domain names almost never arrives in the shape your config file wants. You get hostnames copied out of a CDN dashboard, a column pasted from a spreadsheet, or a block of lines someone dropped into a support ticket. The values are fine. The format is wrong. And the gap between "a list of domains" and "a JSON allowlist array" is the kind of tedious, error-prone retyping that eats ten minutes and still leaves a missing comma somewhere.

The Domain Name List Converter closes that gap. You paste the list, it parses the domains once with a dedicated parser, and then re-emits the same values in whichever format you actually need. The output formats it offers are: one per line, CSV, JSON, Markdown, SQL IN, and a TypeScript union. Switching between them never changes the underlying values, only the way they're wrapped.

The actual problem: hand-quoting domains by hand

Say you have this in front of you, one domain per line:

api.example.com
cdn.example.com
auth.example.com
www.partner-site.net

You need it as a JSON allowlist for a CORS config. The manual route is: add a bracket, wrap every host in double quotes, add a comma after each one except the last, close the bracket. Four lines is annoying. Forty lines is a guaranteed typo, and the typo won't surface until a request gets rejected in staging.

Worse is when the same list needs to go into a database query as a SQL IN clause. Now you're swapping double quotes for single quotes, keeping the commas, and wrapping the whole thing in parentheses. Different syntax, same retyping, fresh chance to miss a quote.

This tool does both transforms in one step. Paste the flat list once, click JSON, and you have the array. Click SQL IN, and you have the clause. Nothing is re-entered.

A worked example: one list, two formats

Take the four-domain list above. Set the output format to JSON and you get a clean array:

[
  "api.example.com",
  "cdn.example.com",
  "auth.example.com",
  "www.partner-site.net"
]

Paste that straight into an allowlist field in a config file or a feature-flag rule. No bracket-balancing, no trailing-comma surprises.

Now switch the same list to SQL IN without touching the input:

IN ('api.example.com', 'cdn.example.com', 'auth.example.com', 'www.partner-site.net')

Drop that into a WHERE domain IN (...) query and you're done. The single quotes are placed, the commas are placed, the parentheses are closed. That's the whole point of the tool: a flat domain list becomes a JSON allowlist array or a SQL IN ('a.com','b.com') clause in one step, instead of you hand-quoting each domain for a config or query.

Need a CSV for a spreadsheet import or an audit log? Switch to CSV. Want a typed constant in your codebase? Switch to TypeScript union and the values come out as a string literal union you can drop into a type. Same source, six framings.

Cleaning the list before you convert

Real lists are messy, so the converter gives you a few controls before the format step. You can keep unique rows only, which matters when three exports of the same tenant all list cdn.example.com. You can sort the normalized output so diffs against last week's allowlist stay readable. And you can choose to preserve invalid rows for review rather than silently dropping them.

That last option is more useful than it sounds. An "invalid" row is an entry the converter can't treat as a real domain: a trailing-dot pile-up like site..com, an underscore inside a label, or a leftover www. glued to junk. Instead of quietly vanishing, those rows stay in the output with a reason attached, so a bad value never gets quoted into your config and never poisons the target table.

If your raw text is wrapped in URLs or buried in prose rather than already being a clean list, start one step earlier with the Domain Name Extractor, then bring the result here to format it. For validation-only passes where you just want to know which hosts are well-formed, the Domain Name List Validator covers that.

How I use it in practice

I keep an allowlist for a small internal API, and it changes just often enough to be annoying. When a partner asks to add two subdomains, the request usually shows up as a chat message with the hosts on separate lines, sometimes with a stray space or a trailing comment. My old habit was to paste them into the JSON file directly and then fix the quoting by hand, which is exactly how I once shipped an allowlist with a domain that had a leading space inside the quotes. It validated as a string and silently never matched anything.

Now I paste the message into the converter, turn on dedupe so I don't re-add a host that's already live, and export JSON. The same cleaned list also goes into a SQL IN clause for the audit query that checks which domains actually hit the endpoint last week. One paste, two artifacts, and the leading-space class of bug is gone because the parser normalizes the value before it ever reaches the output.

When this beats a quick script

You can absolutely write a one-liner to wrap a list in quotes and commas. I've written that one-liner a dozen times. The reasons I reach for the tool anyway: it runs entirely in the browser so a list of internal hostnames never leaves the tab, it handles the messy cases (duplicates, hidden whitespace, malformed rows) without me writing the validation, and it switches between six output shapes instantly when the same list needs to land in a config file and a query and a spreadsheet.

It comfortably handles a few megabytes of host lists pulled from a zone file, a firewall ruleset, or a marketing tracker export, which is more than a copy-paste script wants to deal with. For anything in the hundreds of megabytes, chunk it locally first.

The short version

A domain list is data; a config file, a query, and a typed constant are just three different costumes for that data. The Domain Name List Converter lets you paste the list once and pick the costume: line, CSV, JSON, Markdown, SQL IN, or TypeScript union. Dedupe, sort, and keep-invalid-for-review handle the cleanup; the format buttons handle the wrapping; and your allowlists and IN clauses stop carrying hand-typed quoting mistakes.


Made by Toolora · Updated 2026-06-13