Browsers & softwarePractical guides

Check JSON and SQL formatting: types and a LEFT JOIN counterexample

Formatting improves readability; syntax and business meaning need separate checks. Start with a small typed configuration, then use two customers to see why moving a condition from ON to WHERE loses a customer regardless of indentation. KitNelo’s SQL tool formats text; run queries in your own test database.

Person coding on multiple screens at night
Illustrative photo: Abdullahi Mohamud ✪ · Unsplash License

What changed: Added configuration formatting and type checks, plus runnable SQL join counterexamples, reference rows and troubleshooting.

The practical answer

Compare configuration keys, values, types and array order. Compare SQL rows and NULLs, not indentation alone. The sample account stays the string 0012. Filtering paid in the LEFT JOIN ON clause retains A and B; filtering in WHERE leaves only A.

Start with a five-field JSON acceptance check

This fictional configuration makes every value reviewable. Account 0012 is a string, not the number 12. Zero, false and null must not disappear because they look like “no value.”

  1. Open JSON formatter, paste the input and format it. If syntax fails, inspect quotes, commas and brackets before deleting a reported field.
  2. Compare each field: account is string 0012; retries is number 0; enabled is boolean false; note is null; tags is a two-item array ordered a then b. An empty string, a missing key and null differ.
  3. Only if the target needs YAML, use JSON/YAML conversion on a copy and check a round trip. Finish with the target parser and test environment rather than overwriting the source or experimenting in production.

Copyable configuration

{"account":"0012","retries":0,"enabled":false,"note":null,"tags":["a","b"]}
Demonstration fields only; no real secrets. This checks types, not universal lossless format conversion.

Run the SQL counterexample: one moved condition removes a row

Run this complete script in a disposable SQLite database, never a business database. The editorial example has two customers: A has a paid order; B has none. The second query moves only the paid condition.

  1. To improve readability, put the SELECT statements into SQL formatter and retain before/after copies. Check that ON, WHERE and quoted content have not changed.
  2. Run each version against the same fixture. Expect two Q1 rows and one Q2 row. If B’s status looks blank, confirm that the client means SQL NULL rather than an empty string.
  3. Choose Q1 when the requirement is every customer with any matching paid order; choose Q2 when it is customer rows with a paid order. Repair the condition placement and rerun; restoring indentation alone cannot fix the result.

SQLite setup and both queries

CREATE TABLE customers (id TEXT PRIMARY KEY);
CREATE TABLE orders (customer_id TEXT, status TEXT);
INSERT INTO customers VALUES ('A'), ('B');
INSERT INTO orders VALUES ('A', 'paid');

-- Q1: keep every customer
SELECT c.id, o.status
FROM customers c
LEFT JOIN orders o
  ON o.customer_id = c.id AND o.status = 'paid'
ORDER BY c.id;

-- Q2: keep only rows with a paid order
SELECT c.id, o.status
FROM customers c
LEFT JOIN orders o ON o.customer_id = c.id
WHERE o.status = 'paid'
ORDER BY c.id;
Copy into a local SQLite test database. KitNelo’s SQL formatter does not execute it. Use a fresh empty database when repeating the setup.

Reference rows: SQL NULL is not the string “NULL”
Queryidstatus
Q1Apaid
Q1BSQL NULL
Q2Apaid

SQLite’s SELECT documentation explains NULL-extended outer-join rows and subsequent WHERE filtering. This tiny exercise does not validate production queries, permissions or execution plans.

Check a small configuration field by field

Use this illustrative configuration: {"account":"0012","retries":0,"enabled":false,"note":null,"tags":["a","b"]}. After formatting or JSON→YAML→JSON, account should remain a four-character string, retries a numeric zero, enabled a Boolean false, note null, and tags a two-element array in the same order. Changing account to 12 or false to "false" is observable by an application; it is not a whitespace edit.

The JSON/YAML converter parses and regenerates the destination format. It does not preserve the source document as written. Keep YAML comments and anchor-based editing information in the original. Object-key order changes do not alone establish changed values, whereas array order can matter. If a signature depends on original bytes, preserve the original file: equivalent parsed data does not establish an equivalent byte signature.

Acceptance conditions for the illustrative configuration
FieldPreserveUnintended change
accountString "0012"Number 12
enabledBoolean falseString "false"
notenullEmpty string or an omitted field
tags["a","b"]Sorting or flattening into one string

Add another order: rows are not unique customers

Add one more paid order for A to the same test database, then rerun Q1 and Q2. Q1 returns three rows: A twice and B once. Q2 returns two rows, both A. A join produces matching rows rather than automatically deduplicated customer counts. Define the counting unit before treating query rows as people in a report.

Extension input for the same test database

INSERT INTO orders VALUES ('A', 'paid');
Append only once, then rerun the earlier Q1 and Q2. Repeated insertion keeps increasing the row count.

The current SQL tool uses general formatting without a database connection or dialect selector. Verify proprietary syntax, constraints and returned rows in the appropriate test environment.

Use small failure cases for regex and basic compaction

The regex tool currently uses fixed g, m and u flags. Compare ^cat$ against “cat” and “Cat” to expose case sensitivity; there is no i-flag control. The m flag makes anchors operate on individual lines, so include multiline input. Match positions are JavaScript string indexes, which need not equal visible glyph positions when emoji are present.

The reverse operation in the JavaScript tool performs basic text compaction using regular expressions, rather than full language-aware minification. The // inside const url = "https://example.com/a"; is string content that must survive. Keep the source and use the project’s normal build and tests instead of treating this output as a production bundle. Check CSS strings, URLs and rendered layouts too; a smaller file does not establish equivalent behavior.

Optional tools for a different input or next step

  • Format JSON: Resolve syntax errors before formatting. Verify whether values such as "0012", 12, false and null retained their intended types.
  • Convert JSON and YAML: Round-trip a small nested sample and inspect strings, arrays and nulls. Do not assume a converter preserves comments or YAML-specific features.
  • Test a regular expression: Include a match, a near miss, an empty input and a multiline sample. This tool uses fixed g, m and u flags; inspect the exact matched boundaries before applying the pattern elsewhere.
  • Format SQL: This tool formats generic SQL without a dialect selector. Review joins and filters independently, then verify specific syntax in the target database; formatting does not execute a query.
  • Format or compact CSS: Keep an editable source, then preview affected layouts at narrow and wide widths; smaller source text does not prove visual equivalence.
  • Format JavaScript: Compare the changed source and run the normal application checks. Basic compaction is not a guarantee of semantic equivalence or production optimization.
  • Convert web color values: Use supported six-digit HEX or integer RGB input; HEX conversion also displays HSL. This entry does not provide opacity controls or a text-contrast check.
  • Compare environment files: Compare variable names and added, removed or changed values. Keep masking on when exporting a review list and verify the destination environment separately.

Troubleshoot the layer that actually failed

MDN describes JSON parsing and syntax errors. Parsing establishes a narrower result than application correctness.

Follow the separate Schema and source-evidence checks for structured output. For prose mixed with code fences, inspect Markdown structure instead.

Different failures need different repairs
ObservationCheck firstAcceptance condition
JSON cannot parseQuotes, commas, brackets; keep the sourceValid syntax and matching values/types for all five fields
0012 changes through YAMLLost string typing or quotingRound-trip type checks and target parser pass
SQL loses BIs paid in ON or WHERE?The same fixture returns the business-defined rows
A URL breaks after JavaScript compactionComment stripping inside a stringUse syntax-aware build tooling and run the original tests

Common questions

Does valid JSON satisfy a Schema?

No. Syntax, Schema and agreement with source facts are different checks.

Will YAML comments survive conversion?

Do not assume so. Keep the original and inspect features that the destination format cannot express.

Can formatting prove a regex is safe for all inputs?

No. Test representative boundaries and consider input size and execution behavior in the consuming application.

Further reading & sources

Put the guide into practice

Open the relevant tool, preview the result and check your exported file.

Related articles