
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
Split an English sentence that lacks spaces and accents into separate words.
npm install wordsninja --save
Load package
const WordsNinjaPack = require('wordsninja');
const WordsNinja = new WordsNinjaPack();
Load dictionary
await WordsNinja.loadDictionary(); // First load dictionary
Add word(s)
WordsNinja.addWords('new word');
Parameters
word: The word(s) (string|array)let words = WordsNinja.splitSentence(string, {camelCaseSplitter, capitalizeFirstLetter, joinWords});
Parameters
string: The string for splitoptions
camelCaseSplitter: Split by Camel Case, Default is false (optional)capitalizeFirstLetter: Capitalize First Letter, Default is false (optional)joinWords: Return join words as sentence, Default is false (optional)Example
(async () => {
await WordsNinja.loadDictionary(); // First load dictionary
let string = 'youneedtolearnfromyourmistakes';
let words = WordsNinja.splitSentence(string);
console.log(words);
})();
Result
[ 'you', 'need', 'to', 'learn', 'from', 'your', 'mistakes' ]
let string = 'youneedtolearnfromyourmistakes';
let words = WordsNinja.splitSentence(string,
{
camelCaseSplitter: true, // Camel case splitting
capitalizeFirstLetter: true, // Capitalize first letter of result
joinWords: true // Join words with spaces
}
);
console.log(words);
Result
You Need To Learn From Your Mistakes
You can add new word(s) to dictionary in runtime
WordsNinja.addWords('Parsa'); // Add one word
WordsNinja.addWords(['Parsa', 'Kafi']); // Add one or more words
Example
let string = 'parsayouneedtolearnfromyourmistakes';
WordsNinja.addWords('Parsa');
let words = WordsNinja.splitSentence(string,
{
capitalizeFirstLetter: true, // Capitalize first letter of result
joinWords: true // Join words with spaces
}
);
console.log(words);
Result
Parsa You Need To Learn From Your Mistakes
Algorithm from How to split text without spaces into list of words?. List of words from wordninja python package. Camel case splitter based on split-camelcase-to-words package.
FAQs
Split a English sentence without any spaces nor accents, into words.
The npm package wordsninja receives a total of 18,177 weekly downloads. As such, wordsninja popularity was classified as popular.
We found that wordsninja demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.