DEV Community

Solomon
Solomon

Posted on

I Built a Free Sql Builder — No Signup, No Subscription

I got tired of writing SQL joins by hand. Not because I can't do it — I can — but because every time I sit down to query a new database, I spend fifteen minutes staring at schema diagrams trying to remember which foreign key points where. So I built a tool that takes plain English descriptions and turns them into real, working SQL queries with joins and filters. No signup, no subscription, nothing to install.

👉 Try it now at sql-builder.solomontools.workers.dev

You type something like "Show me all customers who placed orders over $500 in the last 30 days, sorted by total spent" and it gives you a query you can copy straight into your client. It handles JOINs, WHERE clauses, GROUP BY, ORDER BY, and subqueries. It works against any SQL database — PostgreSQL, MySQL, SQLite, SQL Server — because the output is standard SQL you can adapt.

Why I Built This

I've been building tools on the side for a while. Most of them are small utilities that solve a specific problem I personally hit. This one came from a frustrating afternoon where I was writing a report and kept getting my join conditions wrong on a legacy schema I hadn't touched in six months.

I thought: there has to be a way to just describe what I want in English and get correct SQL back. LLMs are good at this. The gap was never the model — it was the plumbing. I wanted something fast, private, and zero-friction. No API keys, no accounts, no data leaving my machine.

That meant I couldn't rely on a heavy backend. I needed edge compute with an AI inference API that could handle a natural language request and return a structured SQL query in milliseconds.

How It Works Under the Hood

The entire app runs on Cloudflare Workers at the edge. Here's the architecture:

  1. Frontend — A single-page app served statically from Cloudflare Pages. It's a text area, a submit button, and a code block for the output. Nothing more.
  2. Worker — When you hit submit, the request hits a Cloudflare Worker at the edge. The worker receives your plain-English prompt, forwards it to an AI inference API, and returns the generated SQL.
  3. AI Inference — I use an edge-compatible LLM API that can generate text quickly. The prompt is engineered to constrain output to valid SQL only, with no preamble, no explanation, just the query.

The key design decision was keeping the AI interaction minimal and deterministic. I don't send your schema to the model — I don't have it. I send a carefully crafted prompt that instructs the model to produce syntactically correct SQL based on common patterns. You then run that query against your own database.

Here's a simplified version of what the worker does:

export default {
  async fetch(request) {
    if (request.method === "POST") {
      const { prompt } = await request.json();
      const sql = await generateSQL(prompt);
      return new Response(JSON.stringify({ sql }), {
        headers: { "Content-Type": "application/json" }
      });
    }
    return new Response(getHTML(), { headers: { "Content-Type": "text/html" } });
  }
};

async function generateSQL(prompt) {
  const response = await fetch("https://api.example.com/v1/chat/completions", {
    method: "POST",
    headers: { "Authorization": `Bearer ${API_KEY}` },
    body: JSON.stringify({
      model: "model-name",
      messages: [{
        role: "system",
        content: "You are a SQL expert. Return ONLY valid SQL. No explanation, no markdown code blocks, no preamble."
      }, {
        role: "user",
        content: prompt
      }]
    })
  });
  const data = await response.json();
  return data.choices[0].message.content.trim();
}
Enter fullscreen mode Exit fullscreen mode

The prompt engineering is where most of the magic lives. I spent a lot of iterations on the system prompt to eliminate hallucinated table names, unnecessary semicolons, and conversational filler. The model needs to behave like a pure function: English in, SQL out.

What I Learned Shipping It

Cold start on the edge is your friend. Because the Worker is at the edge, there's no server to manage, no container to spin up. The first cold start happens once per region and then it's cached. Users in Europe and Asia get served from their nearest PoP, which means sub-200ms response times even with the AI API call.

Prompt engineering matters more than model choice. I tried three different models before settling on one that consistently produced clean SQL. The difference between a good model with a bad prompt and a mediocre model with a great prompt was night and day. I now spend more time on prompt iteration than model selection.

Zero-friction is a feature, not a limitation. I considered adding a login system so users could save queries or share them. I didn't, because every additional step is a drop-off point. The tradeoff is that there's no persistence — if you close the tab, your query is gone. For a free tool, that's fine. Most people just want a quick query and they're done.

CORS and Content-Type headers will haunt you. The first week, the frontend couldn't POST to the Worker because of a missing Access-Control-Allow-Origin header. I also had issues with the Content-Type: application/json header not being set on the response, which caused the frontend fetch() to fail silently. Edge Workers have slightly different behavior than traditional servers, and the debugging is all in the logs dashboard.

Honest Monetization

This tool is free to use. I run it on Cloudflare's free tier, and the AI inference costs are negligible at my current traffic levels. If you find it saves you time, there's an optional one-time $5 contribution on the landing page. No subscriptions, no tiers, no email required to use it. I built it for myself first, and if others find it useful too, that's a bonus.

If you're building something similar or have ideas for improving this, I'd love to hear from you. The code is open and the architecture is simple enough to fork. Sometimes the best tools are the ones that solve one problem well and get out of your way.


Enjoyed this? I build simple, powerful AI tools — try the free Text Summarizer or browse the full toolkit at Solomon Tools. No signup, no subscription.

Top comments (0)