Skip to content

DuckDB Extension

Inflector

Convert string case and inflect English words in DuckDB SQL. Rename struct fields, change camelCase to snake_case, or pluralize labels.

555,317
extension loads · last 90 days
On this page
Sample data for the examples

Each browser example starts with these sample tables; sample files are shared across examples on this page. Run this setup first when trying the examples in your own DuckDB session.

-- Fixtures for inflector cookbook / technical-details / functions.json examples.
-- Small, deterministic, idempotent. Backs snippets that read from
-- `api_events` (struct payload), `models` (class names), `mixed_input`
-- (raw case-mixed strings), and `left_records` / `right_records` (dedupe pair).

CREATE OR REPLACE TABLE api_events (
    id       INTEGER,
    payload  STRUCT(firstName TEXT, lastName TEXT)
);
INSERT INTO api_events VALUES
    (1, {'firstName': 'John',  'lastName': 'Doe'}),
    (2, {'firstName': 'Jane',  'lastName': 'Roe'}),
    (3, {'firstName': 'Mary',  'lastName': 'Sue'});

CREATE OR REPLACE TABLE models (
    class_name  TEXT
);
INSERT INTO models VALUES
    ('UserAccount'),
    ('Message'),
    ('Order');

CREATE OR REPLACE TABLE mixed_input (
    raw  TEXT
);
INSERT INTO mixed_input VALUES
    ('helloWorld'),
    ('HelloWorld'),
    ('hello_world'),
    ('hello-world');

CREATE OR REPLACE TABLE left_records (
    id    INTEGER,
    name  TEXT
);
INSERT INTO left_records VALUES
    (1, 'helloWorld'),
    (2, 'fooBar');

CREATE OR REPLACE TABLE right_records (
    id    INTEGER,
    name  TEXT
);
INSERT INTO right_records VALUES
    (10, 'hello_world'),
    (20, 'foo_bar');

-- Small files for the file-ingestion examples, in the browser's filesystem.
COPY (SELECT 'Ada' AS firstName, 'Lovelace' AS lastName, '[email protected]' AS emailAddress)
TO 'users.csv' (HEADER true);
COPY (SELECT 'Ada' AS firstName, 'Lovelace' AS lastName)
TO 'data.csv' (HEADER true);
COPY (SELECT 'Ada' AS firstName, 'Lovelace' AS lastName)
TO 'events.json' (FORMAT JSON, ARRAY true);

Make names consistent across datasets

Inflector converts strings between conventions such as snake_case, camelCase, and PascalCase. It also provides English pluralization and singularization, plus helpers for rewriting struct keys and result-column names.

Use it when incoming data uses different naming conventions or when an export must match another system’s field names. These are mechanical transformations: they can standardize spelling conventions, but they do not decide whether two differently named fields mean the same thing.

Example

Convert names to snake_case

Apply the same naming convention to two sample field names.

Tested with DuckDB 1.5.6. Browser examples use Haybarn-Wasm 2.0.0-rc12.

SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
  WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL inflector FROM query_farm;
LOAD inflector FROM query_farm;

WITH fields(name) AS (VALUES ('firstName'), ('PostalCode'))
SELECT name, inflector_to_snake_case(name) AS snake_case
FROM fields
ORDER BY name;

Expected result

name snake_case
PostalCode postal_code
firstName first_name

Case conversion changes formatting; it does not establish that two names mean the same thing. English pluralization rules are a separate set of functions.

Common tasks

Deep Dive

Technical Details

Reference

Extension Contents

Quick reference to all available functions and settings organized by category.

Bulk
inflect() Object type: Scalar function Apply a named transform ('camel', 'snake', 'pascal', 'kebab', etc.) to one of: a string, every key in a struct, or every column name in a query result.
Case Transformation
inflector_to_camel_case() Object type: Scalar function Convert to camelCase.
inflector_to_class_case() Object type: Scalar function Convert to ClassCase (PascalCase singular).
inflector_to_kebab_case() Object type: Scalar function Convert to kebab-case (hyphen-separated).
inflector_to_lower_case() Object type: Scalar function Lowercase every character.
inflector_to_pascal_case() Object type: Scalar function Convert to PascalCase.
inflector_to_screamingsnake_case() Object type: Scalar function Convert to SCREAMING_SNAKE_CASE (caps with underscores).
inflector_to_sentence_case() Object type: Scalar function Convert to Sentence case — first letter capital, rest lowercase, words space-separated.
inflector_to_snake_case() Object type: Scalar function Convert to snake_case.
inflector_to_title_case() Object type: Scalar function Convert to Title Case — every word capitalized, space-separated.
inflector_to_train_case() Object type: Scalar function Convert to Train-Case (capitalized hyphenated).
inflector_to_upper_case() Object type: Scalar function Uppercase every character.
Configuration
inflector_acronyms Object type: Setting List of acronyms preserved as uppercase in case conversions (e.g., HTML, API).
Functions
inflector_deconstantize() Object type: Scalar function Removes the rightmost segment from a constant expression
inflector_demodulize() Object type: Scalar function Removes the module part from a fully qualified name
inflector_deordinalize() Object type: Scalar function Removes the ordinal suffix from a string (1st -> 1)
inflector_is_camel_case() Object type: Scalar function Returns true if the string is in camelCase format
inflector_is_class_case() Object type: Scalar function Returns true if the string is in ClassCase (PascalCase) format
inflector_is_foreign_key() Object type: Scalar function Returns true if the string is in foreign key format (ends with _id)
inflector_is_kebab_case() Object type: Scalar function Returns true if the string is in kebab-case format
inflector_is_pascal_case() Object type: Scalar function Returns true if the string is in PascalCase format
inflector_is_screamingsnake_case() Object type: Scalar function Returns true if the string is in SCREAMING_SNAKE_CASE format
inflector_is_sentence_case() Object type: Scalar function Returns true if the string is in Sentence case format
inflector_is_snake_case() Object type: Scalar function Returns true if the string is in snake_case format
inflector_is_table_case() Object type: Scalar function Returns true if the string is in table_case format (snake_case plural)
inflector_is_title_case() Object type: Scalar function Returns true if the string is in Title Case format
inflector_is_train_case() Object type: Scalar function Returns true if the string is in Train-Case format
inflector_ordinalize() Object type: Scalar function Converts a number string to its ordinal form (1st, 2nd, 3rd, etc.)
inflector_to_foreign_key() Object type: Scalar function Converts a class name to a foreign key column name
Inflection
inflector_to_plural() Object type: Scalar function Pluralize an English word — handles irregulars (person→people, mouse→mice).
inflector_to_singular() Object type: Scalar function Singularize an English word.
Naming Helpers
inflector_classify() Object type: Scalar function Turn a table name into a class name, like Rails classify: the last word is singularized and the result is rendered in PascalCase.
inflector_humanize() Object type: Scalar function Turn an identifier into a human-readable label, like Rails humanize: a trailing _id is dropped and the rest is rendered in Sentence case.
inflector_parameterize() Object type: Scalar function Build a URL slug: accents are removed, letters are lowercased, and every run of characters that are not letters or digits becomes a single -, with no leading or trailing dash.
inflector_to_table_case() Object type: Scalar function Rails-style 'table_case' — snake_case + plural.

API Reference

Function Reference

Configuration

Settings

Configure the inflector extension behavior using these settings.

inflector_acronyms

VARCHAR[] Configuration
Default Value: []

Practical Examples

Cookbook

Real-world recipes and patterns for common use cases.

Platform Support

Compatibility

Extension availability may vary by platform and DuckDB version. Check below to ensure this extension supports your environment before installation.

Quick Facts

Release status Stable
Software License MIT
Pricing Free
Written In Rust
Source Available Yes
View on GitHub
Usage
555,317
loads · last 90 days

Platforms

DuckDB 2.0.0

  • Linux x86_64aarch64
  • Linux (musl) Not available
  • macOS Apple Silicon
  • Windows x86_64x86_64 (MinGW)
  • WASM Not available
Compiled binary sizes
Platform Architecture Size
Linux x86_64 5.83 MB
Linux aarch64 5.11 MB
macOS Apple Silicon 3.62 MB
Windows x86_64 10.84 MB
Windows x86_64 (MinGW) 19.93 MB

Compressed download sizes for the release shown above.

DuckDB & Haybarn

Release calendar
  • DuckDB v2.0.0 Query.Farm repository Supported
  • Haybarn v1.5.6 Built-in community repository Supported

Browser examples use Haybarn-Wasm 2.0.0-rc12.

Checked .

Learn and explore

Tutorials and articles

Writing about Inflector: how it works, what changed, and why.