Need to convert text to snake_case format? This guide covers everything about snake_case conversion via API, including when to use snake_case, naming conventions, and implementation examples in multiple programming languages.
What is snake_case?
snake_case is a naming convention where words are separated by underscores and all letters are lowercase. It's called snake_case because the underscores look like a snake on the ground connecting the words.
Example: Hello World Example becomes hello_world_example
When to Use snake_case
snake_case is commonly used in:
Python
Functions, variables, and module names follow snake_case convention (PEP 8).
Ruby
Methods and variables use snake_case by convention.
Databases
Table names and column names often use snake_case.
Using the snake_case Converter API
TinyFn provides a simple endpoint to convert text to snake_case:
POST https://api.tinyfn.io/v1/text/snakecase
Headers: X-API-Key: your-api-key
Content-Type: application/json
{
"text": "Hello World Example"
}
{
"snake_case": "hello_world_example",
"original": "Hello World Example"
}
Parameters
| Parameter | Type | Description |
|---|---|---|
text |
string | The text to convert (required) |
screaming |
boolean | Convert to SCREAMING_SNAKE_CASE (default: false) |
Code Examples
JavaScript / Node.js
const response = await fetch(
'https://api.tinyfn.io/v1/text/snakecase',
{
method: 'POST',
headers: {
'X-API-Key': 'your-api-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({ text: 'userFirstName' })
}
);
const result = await response.json();
console.log(result.snake_case); // user_first_name
Python
import requests
response = requests.post(
'https://api.tinyfn.io/v1/text/snakecase',
headers={'X-API-Key': 'your-api-key'},
json={'text': 'userFirstName'}
)
result = response.json()['snake_case']
print(result) # user_first_name
cURL
curl -X POST "https://api.tinyfn.io/v1/text/snakecase" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{"text": "userFirstName"}'
Common Use Cases
- Database Columns: Convert API field names to database column names
- Python Code: Generate Python-compliant variable names
- File Names: Create consistent file naming conventions
- API Normalization: Convert between different API naming conventions
- ORM Mapping: Map camelCase model fields to snake_case columns
Best Practices
- Consistency: Use snake_case throughout your Python/Ruby codebase
- All lowercase: snake_case should always be lowercase (except SCREAMING)
- No double underscores: Avoid multiple consecutive underscores
- Start with letter: Don't start names with numbers or underscores
Use via MCP
Your AI agent can call this tool directly via Model Context Protocol — no HTTP code needed. Add TinyFn to Claude Desktop, Cursor, or any MCP client:
{
"mcpServers": {
"tinyfn-text": {
"url": "https://api.tinyfn.io/mcp/text/",
"headers": {
"X-API-Key": "your-api-key"
}
}
}
}
See all text analysis tools available via MCP in our Text Analysis MCP Tools for AI Agents guide.
Try the snake_case Converter API
Get your free API key and start converting text in seconds.
Get Free API Key