Convert text with only the first character in lower case
npm install text-lower-case-first[![NPM version][npm-image]][npm-url]
[![NPM downloads][downloads-image]][downloads-url]
[![Bundle size][bundlephobia-image]][bundlephobia-url]


> Transform text by making the first character lowercase while preserving the rest.
- Lightweight - Only ~200B minified + gzipped
- Type-safe - Full TypeScript support with comprehensive type definitions
- Zero dependencies - No external dependencies
- Tree-shakeable - ES modules support
- Universal - Works in browsers, Node.js, and serverless environments
- Well-tested - Comprehensive test suite with edge cases
``bashnpm
npm install text-lower-case-first
π― Quick Start
`javascript
import { lowerCaseFirst } from "text-lower-case-first";console.log(lowerCaseFirst("Hello World")); // "hello World"
console.log(lowerCaseFirst("HELLO WORLD")); // "hELLO WORLD"
console.log(lowerCaseFirst("CamelCase")); // "camelCase"
`π Usage
$3
`javascript
import { lowerCaseFirst } from "text-lower-case-first";console.log(lowerCaseFirst("Hello")); // "hello"
`$3
`javascript
const { lowerCaseFirst } = require("text-lower-case-first");console.log(lowerCaseFirst("Hello")); // "hello"
`$3
`typescript
import { lowerCaseFirst } from "text-lower-case-first";const result: string = lowerCaseFirst("Hello World");
console.log(result); // "hello World"
`π Transformation Examples
$3
`javascript
import { lowerCaseFirst } from "text-lower-case-first";// Simple cases
lowerCaseFirst("Hello"); // "hello"
lowerCaseFirst("hello"); // "hello"
lowerCaseFirst("HELLO"); // "hELLO"
// Multiple words
lowerCaseFirst("Hello World"); // "hello World"
lowerCaseFirst("HELLO WORLD"); // "hELLO WORLD"
lowerCaseFirst("hello world"); // "hello world"
// Programming cases
lowerCaseFirst("CamelCase"); // "camelCase"
lowerCaseFirst("PascalCase"); // "pascalCase"
lowerCaseFirst("Snake_case"); // "snake_case"
lowerCaseFirst("Kebab-case"); // "kebab-case"
`$3
`javascript
import { lowerCaseFirst } from "text-lower-case-first";// Empty and single character
lowerCaseFirst(""); // ""
lowerCaseFirst("A"); // "a"
lowerCaseFirst("a"); // "a"
// Numbers and symbols
lowerCaseFirst("123hello"); // "123hello"
lowerCaseFirst("@Hello"); // "@Hello"
lowerCaseFirst("Hello123"); // "hello123"
// Unicode characters
lowerCaseFirst("Γice"); // "Γ±ice"
lowerCaseFirst("Γber"); // "ΓΌber"
lowerCaseFirst("CafΓ©"); // "cafΓ©"
`π Real-World Examples
$3
`javascript
import { lowerCaseFirst } from "text-lower-case-first";// Convert PascalCase to camelCase
lowerCaseFirst("UserProfile"); // "userProfile"
lowerCaseFirst("DatabaseConnection"); // "databaseConnection"
lowerCaseFirst("ApiResponse"); // "apiResponse"
lowerCaseFirst("HttpClient"); // "httpClient"
`$3
`javascript
import { lowerCaseFirst } from "text-lower-case-first";function convertObjectKeys(obj) {
const converted = {};
for (const [key, value] of Object.entries(obj)) {
const newKey = lowerCaseFirst(key);
converted[newKey] =
typeof value === "object" && value !== null
? convertObjectKeys(value)
: value;
}
return converted;
}
const apiResponse = {
UserName: "john_doe",
EmailAddress: "john@example.com",
ProfileData: {
FirstName: "John",
LastName: "Doe",
PhoneNumber: "123-456-7890",
},
};
console.log(convertObjectKeys(apiResponse));
// {
// userName: "john_doe",
// emailAddress: "john@example.com",
// profileData: {
// firstName: "John",
// lastName: "Doe",
// phoneNumber: "123-456-7890"
// }
// }
`$3
`javascript
import { lowerCaseFirst } from "text-lower-case-first";function createGetter(propertyName) {
const methodName =
get${propertyName};
return lowerCaseFirst(methodName);
}function createSetter(propertyName) {
const methodName =
set${propertyName};
return lowerCaseFirst(methodName);
}console.log(createGetter("UserName")); // "getUserName"
console.log(createSetter("EmailAddress")); // "setEmailAddress"
console.log(createGetter("IsActive")); // "getIsActive"
`$3
`javascript
import { lowerCaseFirst } from "text-lower-case-first";function processFormFields(fields) {
const processed = {};
fields.forEach((field) => {
// Convert field names to camelCase
const fieldName = lowerCaseFirst(field.Name || field.name);
processed[fieldName] = {
value: field.Value || field.value || "",
required: field.Required || field.required || false,
type: field.Type || field.type || "text",
};
});
return processed;
}
const formFields = [
{ Name: "FirstName", Value: "John", Required: true, Type: "text" },
{ Name: "LastName", Value: "Doe", Required: true, Type: "text" },
{ Name: "EmailAddress", Value: "", Required: true, Type: "email" },
];
console.log(processFormFields(formFields));
// {
// firstName: { value: "John", required: true, type: "text" },
// lastName: { value: "Doe", required: true, type: "text" },
// emailAddress: { value: "", required: true, type: "email" }
// }
`$3
`javascript
import { lowerCaseFirst } from "text-lower-case-first";function normalizeApiResponse(response) {
if (Array.isArray(response)) {
return response.map(normalizeApiResponse);
}
if (typeof response === "object" && response !== null) {
const normalized = {};
for (const [key, value] of Object.entries(response)) {
const normalizedKey = lowerCaseFirst(key);
normalized[normalizedKey] = normalizeApiResponse(value);
}
return normalized;
}
return response;
}
const apiData = {
UserId: 123,
UserName: "john_doe",
ProfileInfo: {
FirstName: "John",
LastName: "Doe",
ContactDetails: {
EmailAddress: "john@example.com",
PhoneNumber: "123-456-7890",
},
},
Preferences: [
{ SettingName: "theme", SettingValue: "dark" },
{ SettingName: "language", SettingValue: "en" },
],
};
console.log(normalizeApiResponse(apiData));
// {
// userId: 123,
// userName: "john_doe",
// profileInfo: {
// firstName: "John",
// lastName: "Doe",
// contactDetails: {
// emailAddress: "john@example.com",
// phoneNumber: "123-456-7890"
// }
// },
// preferences: [
// { settingName: "theme", settingValue: "dark" },
// { settingName: "language", settingValue: "en" }
// ]
// }
`$3
`javascript
import { lowerCaseFirst } from "text-lower-case-first";class CodeGenerator {
generateProperty(name, type = "string") {
const propertyName = lowerCaseFirst(name);
return
private ${propertyName}: ${type};;
} generateGetter(name, type = "string") {
const propertyName = lowerCaseFirst(name);
const methodName =
get${name};
return public ${lowerCaseFirst(methodName)}(): ${type} {;
} generateSetter(name, type = "string") {
const propertyName = lowerCaseFirst(name);
const methodName =
set${name};
const paramName = lowerCaseFirst(name);
return public ${lowerCaseFirst(methodName)}(${paramName}: ${type}): void {;
}
}const generator = new CodeGenerator();
console.log(generator.generateProperty("UserName"));
// "private userName: string;"
console.log(generator.generateGetter("UserName"));
// "public getUserName(): string {
// return this.userName;
// }"
`$3
`javascript
import { lowerCaseFirst } from "text-lower-case-first";function processConfiguration(config) {
const processed = {};
for (const [section, settings] of Object.entries(config)) {
const sectionName = lowerCaseFirst(section);
processed[sectionName] = {};
for (const [key, value] of Object.entries(settings)) {
const settingName = lowerCaseFirst(key);
processed[sectionName][settingName] = value;
}
}
return processed;
}
const appConfig = {
DatabaseSettings: {
ConnectionString: "localhost:5432",
MaxConnections: 100,
TimeoutSeconds: 30,
},
ApiSettings: {
BaseUrl: "https://api.example.com",
ApiKey: "secret-key",
RateLimitPerMinute: 1000,
},
};
console.log(processConfiguration(appConfig));
// {
// databaseSettings: {
// connectionString: "localhost:5432",
// maxConnections: 100,
// timeoutSeconds: 30
// },
// apiSettings: {
// baseUrl: "https://api.example.com",
// apiKey: "secret-key",
// rateLimitPerMinute: 1000
// }
// }
`π API Reference
$3
Makes the first character of a string lowercase while preserving the rest.
#### Parameters
-
input (string): The string to transform#### Returns
-
string: The string with the first character in lowercaseπ Bundle Size
This package is optimized for minimal bundle size:
- Minified: ~200B
- Gzipped: ~150B
- Tree-shakeable: Yes
- Side effects: None
π Browser Support
- Modern browsers: ES2015+ (Chrome 51+, Firefox 54+, Safari 10+)
- Node.js: 12+
- TypeScript: 4.0+
- Bundle formats: UMD, ESM, CommonJS
π§ͺ Testing
`bash
Run tests
pnpm testRun tests in watch mode
pnpm test --watchRun tests with coverage
pnpm test --coverageType checking
pnpm typecheckLinting
pnpm lint
`π Related Packages
text-camel-case - Convert to camelCase
- text-capital-case - Convert to Capital Case
- text-constant-case - Convert to CONSTANT_CASE
- text-dot-case - Convert to dot.case
- text-header-case - Convert to Header-Case
- text-case - All case transformations in one packageπ License
π€ Contributing
1. Fork the repository
2. Create your feature branch (
git checkout -b feature/amazing-feature)
3. Commit your changes (git commit -m 'Add some amazing feature')
4. Push to the branch (git push origin feature/amazing-feature`)- π§ Email: selikhov.dmitrey@gmail.com
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
- π Documentation: Full Documentation
---
Made with β€οΈ by Dmitry Selikhov
[npm-image]: https://img.shields.io/npm/v/text-lower-case-first.svg?style=flat
[npm-url]: https://npmjs.org/package/text-lower-case-first
[downloads-image]: https://img.shields.io/npm/dm/text-lower-case-first.svg?style=flat
[downloads-url]: https://npmjs.org/package/text-lower-case-first
[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/text-lower-case-first.svg
[bundlephobia-url]: https://bundlephobia.com/result?p=text-lower-case-first