Skip to main content

Snake Case

Text Processing String Manipulation

Synopsis

Converts strings to snake_case format.

Schema

- snakecase:
field: <ident>
target_field: <string>
fields: <array>
exclude: <array>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>

Configuration

The following fields are used to define the processor:

FieldRequiredDefaultDescription
fieldN-Selects value mode: converts the value of this field to snake_case. The value must be a string or an array of strings. Mutually exclusive with fields — when field is set, fields and exclude are ignored
target_fieldNSame as fieldWhere the converted value is written in value mode. Ignored in name mode
fieldsN["*"]Selects name mode: glob patterns matching field names to rename to snake_case. The values are left untouched. a.* renames the keys inside object a, *.* those of every root object. Omitting both field and fields renames every root-level field name; names beginning with _ are never renamed
excludeN-Field names to leave alone in name mode. Has no effect in value mode
descriptionN-Explanatory note
ifN-Condition to run
ignore_failureNfalseContinue processing if conversion fails
ignore_missingNfalseSkip processing if referenced field doesn't exist
on_failureN-See Handling Failures
on_successN-See Handling Success
tagN-Identifier
disabledNfalseWhen true, the processor is skipped and the event continues to the next one. Lets you take a processor out of the path without removing its configuration

Details

Converts string values to snake_case format by replacing spaces, hyphens, dots, and other separators with underscores, then converting all characters to lowercase. This format is commonly used in programming languages like Python, Ruby, and database naming conventions.

The processor handles various input formats including camelCase, PascalCase, kebab-case, and space-separated words, normalizing them to the consistent snake_case style.

note

snake_case format uses underscores as separators and converts all text to lowercase, resulting in format like "user_name", "api_response_data", or "system_config_value". It's widely used in Python and database schemas.

The processor preserves the logical word boundaries from the input while standardizing the format for consistent usage in code and data storage.

warning

Consecutive separators in the input may result in multiple consecutive underscores in the output. The processor does not automatically clean up redundant separators.

Examples

Basic Conversion

Converting camelCase to snake_case...

{
"fieldName": "userAccountSettings"
}
- snakecase:
field: fieldName
target_field: snake_name

converts to snake_case:

{
"fieldName": "userAccountSettings",
"snake_name": "user_account_settings"
}

Database Column Names

Creating database-friendly column names...

{
"columnTitle": "Customer Email Address"
}
- snakecase:
field: columnTitle
target_field: column_name

generates database column name:

{
"columnTitle": "Customer Email Address",
"column_name": "customer_email_address"
}

Mixed Format Input

Normalizing mixed separators to snake_case...

{
"variableName": "api-response.data with spaces"
}
- snakecase:
field: variableName

standardizes all separators:

{
"variableName": "api_response_data_with_spaces"
}

Multiple Fields

Renaming field names to snake_case, leaving values untouched...

{
"firstName": "John Doe",
"lastName": "Smith Williams",
"emailAddress": "john.doe@example.com"
}
- snakecase:
fields: ["firstName", "lastName", "emailAddress"]

renames the matched names; the values are unchanged:

{
"first_name": "John Doe",
"last_name": "Smith Williams",
"email_address": "john.doe@example.com"
}

Configuration Keys

Creating configuration key names...

{
"settingName": "Maximum Connection Timeout"
}
- snakecase:
field: settingName
target_field: config_key

generates configuration key:

{
"settingName": "Maximum Connection Timeout",
"config_key": "maximum_connection_timeout"
}