or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

index.mddocs/

lodash.deburr

lodash.deburr provides a utility function that removes diacritics (accent marks) from latin-1 supplementary letters, converting them to their basic latin equivalents. This is useful for text normalization, search functionality, URL slug generation, and internationalization scenarios where accent-insensitive processing is required.

Package Information

  • Package Name: lodash.deburr
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install lodash.deburr or use from full lodash library

Core Imports

For standalone lodash.deburr package:

const deburr = require('lodash.deburr');

From full lodash library:

const _ = require('lodash');
// Use as _.deburr()

ES6 modules (if available):

import deburr from 'lodash.deburr';

Basic Usage

const deburr = require('lodash.deburr');

// Remove accents from common phrases
const result1 = deburr('déjà vu');
// => 'deja vu'

const result2 = deburr('naïve café');
// => 'naive cafe'

const result3 = deburr('Zürich résumé');
// => 'Zurich resume'

// Handle empty or null values gracefully
const result4 = deburr('');
// => ''

const result5 = deburr(null);
// => ''

const result6 = deburr(undefined);
// => ''

Capabilities

String Deburring

Converts latin-1 supplementary letters (accented characters) to their basic latin equivalents while preserving other characters.

/**
 * Deburrs string by converting latin-1 supplementary letters to basic latin letters.
 * 
 * @param {string} [string=''] - The string to deburr
 * @returns {string} Returns the deburred string
 */
function deburr(string)

Behavior:

  • Converts accented vowels: á, à, â, ã, ä, å → a
  • Converts accented consonants: ç → c, ñ → n
  • Converts special characters: æ → ae, ø → o, ß → ss
  • Preserves mathematical operators: × and ÷ remain unchanged
  • Handles null/undefined input by returning empty string
  • Non-string inputs are converted to string first

Usage Examples:

// Basic accent removal
deburr('Crème brûlée'); // => 'Creme brulee'
deburr('piña colada');  // => 'pina colada'

// URL slug generation
function createSlug(text) {
  return deburr(text)
    .toLowerCase()
    .replace(/[^a-z0-9]+/g, '-')
    .replace(/-+/g, '-')
    .replace(/^-|-$/g, '');
}

createSlug('Café París'); // => 'cafe-paris'

// Search normalization
function normalizeForSearch(query) {
  return deburr(query).toLowerCase();
}

const searchTerms = ['café', 'cafe'];
const normalizedTerms = searchTerms.map(normalizeForSearch);
// => ['cafe', 'cafe'] - now identical for matching

// Form data cleaning
const userInput = 'José María González';
const cleanedName = deburr(userInput);
// => 'Jose Maria Gonzalez'

Character Mappings:

The function handles these latin-1 supplementary letter ranges:

  • À-Ö (uppercase accented letters): À→A, Á→A, Â→A, etc.
  • Ø-Þ (other uppercase): Ø→O, Ð→D, Þ→Th, etc.
  • ß-ö (lowercase accented): ß→ss, à→a, á→a, etc.
  • ø-ÿ (other lowercase): ø→o, ð→d, þ→th, ÿ→y

Edge Cases:

  • Mathematical operators (× ÷) are preserved unchanged
  • Non-latin characters outside the latin-1 range are unchanged
  • Whitespace and punctuation are preserved
  • Numbers and basic ASCII letters are unchanged