From 88f3b2a9214dc669fdf0e4a50bd0734118e8e71a Mon Sep 17 00:00:00 2001 From: Prasang Singhal Date: Sun, 23 Mar 2025 18:39:48 +0530 Subject: [PATCH 1/5] feat: sql minifier utility --- components/seo/SQLMinifierSEO.tsx | 73 ++++++++++++++++++++++++++++ components/utils/tools-list.ts | 6 +++ pages/utilities/sql-minifier.tsx | 80 +++++++++++++++++++++++++++++++ 3 files changed, 159 insertions(+) create mode 100644 components/seo/SQLMinifierSEO.tsx create mode 100644 pages/utilities/sql-minifier.tsx diff --git a/components/seo/SQLMinifierSEO.tsx b/components/seo/SQLMinifierSEO.tsx new file mode 100644 index 0000000..a23567d --- /dev/null +++ b/components/seo/SQLMinifierSEO.tsx @@ -0,0 +1,73 @@ +export default function SQLMinifierSEO() { + return ( +
+
+

+ You can use this SQL Minifier to clean and optimize your SQL queries + by removing comments and extra spaces. Just paste your SQL and get a + minified result instantly. Made with 💜 by the developers building + Jam. +

+
+ +
+

How to Use the SQL Minifier

+

+ Whether you're working with large queries or optimizing database + performance, our SQL Minifier helps streamline your SQL code in + seconds—no signup required. +

+

+ The tool ensures your SQL remains functional while improving + readability and execution speed. +

+
+ +
+

Benefits of Minifying SQL

+

+ Minified SQL reduces unnecessary whitespace and removes comments, + making queries more efficient and easier to process. +

+
    +
  • + Performance Optimization:
    Minified SQL runs faster by + eliminating extra spaces and comments. +
  • +
  • + Reduced Query Size:
    Smaller queries help in better + database management and quicker execution. +
  • +
  • + Clean Code:
    Removing comments and extra whitespace + results in neater, more readable queries. +
  • +
+
+ +
+

FAQs

+
    +
  • + What does the SQL Minifier do?
    It removes comments, + extra spaces, and unnecessary formatting to create optimized SQL + queries. +
  • +
  • + Does minifying SQL improve performance?
    Yes, minified + SQL executes slightly faster and is easier to store and transfer. +
  • +
  • + Will my SQL logic remain intact?
    Absolutely! This tool + only removes unnecessary characters without altering the query + logic. +
  • +
  • + Is the SQL Minifier free?
    Yes, it's completely free + and accessible without any signup or installation. +
  • +
+
+
+ ); +} diff --git a/components/utils/tools-list.ts b/components/utils/tools-list.ts index ac99700..ef41923 100644 --- a/components/utils/tools-list.ts +++ b/components/utils/tools-list.ts @@ -143,4 +143,10 @@ export const tools = [ "Convert images to WebP format with batch processing and quality control. Reduce file sizes while maintaining image quality.", link: "/utilities/webp-converter", }, + { + title: "SQL Minifier", + description: + "Minify SQL by removing comments, extra spaces, and formatting for cleaner, optimized queries.", + link: "/utilities/sql-minifier", + }, ]; diff --git a/pages/utilities/sql-minifier.tsx b/pages/utilities/sql-minifier.tsx new file mode 100644 index 0000000..0ed9c10 --- /dev/null +++ b/pages/utilities/sql-minifier.tsx @@ -0,0 +1,80 @@ +import { useCallback, useState } from "react"; +import { Textarea } from "@/components/ds/TextareaComponent"; +import PageHeader from "@/components/PageHeader"; +import { Card } from "@/components/ds/CardComponent"; +import { Button } from "@/components/ds/ButtonComponent"; +import { Label } from "@/components/ds/LabelComponent"; +import Header from "@/components/Header"; +import { useCopyToClipboard } from "@/components/hooks/useCopyToClipboard"; +import { CMDK } from "@/components/CMDK"; +import CallToActionGrid from "../../components/CallToActionGrid"; +import Meta from "@/components/Meta"; +import SQLMinifierSEO from "@/components/seo/SQLMinifierSEO"; + +export default function SQLMinifier() { + const [input, setInput] = useState(""); + const [output, setOutput] = useState(""); + const { buttonText, handleCopy } = useCopyToClipboard(); + + const handleChange = useCallback( + (event: React.ChangeEvent) => { + const { value } = event.currentTarget; + setInput(value); + + try { + let sql = value; + sql = sql.replace(/\/\*[\s\S]*?\*\/|--.*$/gm, ""); + sql = sql.replace(/\s+/g, " ").trim(); + + setOutput(sql); + } catch { + setOutput("Invalid SQL input"); + } + }, + [] + ); + + return ( +
+ +
+ + +
+ +
+ +
+ +
+ +