onlinestringtools logo

Netstring creator

World's simplest string tool

Free online string to netstring creator. Just load your string and it will automatically get converted to a netstring. Load a string – get a netstring. There are no ads, popups or nonsense, just an awesome netstring encoder. Created for developers by developers from team Browserling.
announcement a new project!
Super exciting news! We just launched MATHURLS – a fun math news reader. Check it out!
Netstring Format
Prefix the output by the length of the string.
Convert the string to hex numbers and wrap them in angle braces.
Note that the netstring encoding counts the number of 8-bit units and not the number of characters in a string. Thus, some Unicode symbols can correspond to two, three, or four 8-bit units.
Netstring Encoding Options
Convert each word to a netstring individually.
Convert each line to a netstring individually.
Recursively encode the output string the second time.
Spaces, Tabs, and Newlines
Remove spaces that appear more than once.
Visualize line feeds as "↵". (Works only when multi-line is off.)
Visualize spaces as "⎵".
Visualize tabs as "⇥".
Netstring creator tool What is a netstring creator?
This browser-based tool constructs a netstring from a regular string. A netstring is a safe and reliable encoding method for transmitting regular strings as byte streams over networks or for serialization. It counts the number of 8-bit units in the string and stores this number in front of the string for easy parsing. A netstring can be represented in two different formats – as a length-prefixed string or as a series of hexadecimal numbers. A length-prefixed string format begins with ASCII digits that indicate the length of the data (number of bytes), then a colon, then the string itself, and a comma at the end. For example, the word "butterfly" gets encoded to "9:butterfly," and an empty string gets encoded to "0:,". In the hex format, the input string is first converted to UTF8 bytes and then these bytes are printed as hexadecimal values with a pair of angle brackets around them. In this case, the word "butterfly" gets encoded to <39 3a 62 75 74 74 65 72 66 6c 79 2c> and the empty line gets encoded to <30 3a 2c>. If your string contains several words, then it can be encoded in two ways – word-by-word or as a single long string. If you enter several text lines in the input, you can encode them as a whole or separately line-by-line. These encoding methods are easy to control via the "Encode Words" and "Multi-line" options. You can also activate the "Double Protection" option, which runs the netstring algorithm on the result the second time. If your string contains duplicate spaces, you can get rid of them via the "Skip Repeated Spaces" option. Also, you can prettify whitespace characters by replacing newlines with the "↵" symbol, regular spaces with the "⎵" symbol, and tabs with the "⇥" symbol. Stringabulous!
Netstring creator examples Click to use
Encode Three Words
In this example, we convert three simple words to a netstring. We encode each word individually and print them together. As you can see, each word is encoded as its letter count, followed by a colon character, the word itself, and a comma. The spaces between the words aren't encoded because it's easy to deduce where they go (in place of commas).
every moment matters
5:every,6:moment,7:matters,
Required options
These options will be used automatically if you select this example.
Prefix the output by the length of the string.
Convert each word to a netstring individually.
Convert each line to a netstring individually.
Recursively encode the output string the second time.
Remove spaces that appear more than once.
Visualize line feeds as "↵". (Works only when multi-line is off.)
Visualize spaces as "⎵".
Visualize tabs as "⇥".
Recursive Netstring
This example applies the double protection algorithm to the quote by Oscar Wilde. First, it creates netstrings of all words and then recursively creates another netstring from the previous netstring.
This suspense is terrible. I hope it will last.
66:4:This,8:suspense,2:is,9:terrible.,1:I,4:hope,2:it,4:will,5:last.,,
Required options
These options will be used automatically if you select this example.
Prefix the output by the length of the string.
Convert each word to a netstring individually.
Convert each line to a netstring individually.
Recursively encode the output string the second time.
Remove spaces that appear more than once.
Visualize line feeds as "↵". (Works only when multi-line is off.)
Visualize spaces as "⎵".
Visualize tabs as "⇥".
Music Genres
In this example, we encode a list of music genres and output them in the hexadecimal netstring notation. This notation is the hexadecimal representation of a regular netstring wrapped in angle brackets. First, each genre is converted to a netstring, then all characters of this netstring are converted to base-16, and are placed between angle brackets. As the multi-line mode is active, we get eight separate hex netstrings for each genre.
Rock Electronic Funk Country Latin Reggae Hip hop House
<34 3a 52 6f 63 6b 2c> <31 30 3a 45 6c 65 63 74 72 6f 6e 69 63 2c> <34 3a 46 75 6e 6b 2c> <37 3a 43 6f 75 6e 74 72 79 2c> <35 3a 4c 61 74 69 6e 2c> <36 3a 52 65 67 67 61 65 2c> <37 3a 48 69 70 20 68 6f 70 2c> <35 3a 48 6f 75 73 65 2c>
Required options
These options will be used automatically if you select this example.
Convert the string to hex numbers and wrap them in angle braces.
Convert each word to a netstring individually.
Convert each line to a netstring individually.
Recursively encode the output string the second time.
Remove spaces that appear more than once.
Visualize line feeds as "↵". (Works only when multi-line is off.)
Visualize spaces as "⎵".
Visualize tabs as "⇥".
Bill Wilson's Quote
In this example, we have loaded a quote by Bill Wilson as the input. Unfortunately, it contains many extra spaces that we don't really want to process. To remove them, we have activated the skip-duplicate spaces option. We also process each line and each word individually. As there are four lines and four words per line, we get sixteen netstrings in the output.
To the world you may be one person, but to one person you are the world.
2:To,3:the,5:world,3:you, 3:may,2:be,3:one,7:person,, 3:but,2:to,3:one,6:person, 3:you,3:are,3:the,6:world.,
Required options
These options will be used automatically if you select this example.
Prefix the output by the length of the string.
Convert each word to a netstring individually.
Convert each line to a netstring individually.
Recursively encode the output string the second time.
Remove spaces that appear more than once.
Visualize line feeds as "↵". (Works only when multi-line is off.)
Visualize spaces as "⎵".
Visualize tabs as "⇥".
List of Flowers
This example constructs a recursive netstring of a list of flowers. First, it counts the number of chars in every flower name and constructs a netstring for every flower. Then, it finds the length of this netstring and constructs a second netstring from it. The output format is selected as a hex-byte-string that prints the netstring chars as hex sequences between angle brackets.
Tulip Bluebell Rose Snowdrop Orchid Peony Chrysanthemum Lily Lotus
<38 3a 35 3a 54 75 6c 69 70 2c 2c> <31 31 3a 38 3a 42 6c 75 65 62 65 6c 6c 2c 2c> <37 3a 34 3a 52 6f 73 65 2c 2c> <31 31 3a 38 3a 53 6e 6f 77 64 72 6f 70 2c 2c> <39 3a 36 3a 4f 72 63 68 69 64 2c 2c> <38 3a 35 3a 50 65 6f 6e 79 2c 2c> <31 37 3a 31 33 3a 43 68 72 79 73 61 6e 74 68 65 6d 75 6d 2c 2c> <37 3a 34 3a 4c 69 6c 79 2c 2c> <38 3a 35 3a 4c 6f 74 75 73 2c 2c>
Required options
These options will be used automatically if you select this example.
Convert the string to hex numbers and wrap them in angle braces.
Convert each word to a netstring individually.
Convert each line to a netstring individually.
Recursively encode the output string the second time.
Remove spaces that appear more than once.
Visualize line feeds as "↵". (Works only when multi-line is off.)
Visualize spaces as "⎵".
Visualize tabs as "⇥".
Holiday Checklist
In this example, we create one long netstring from nine shorter strings. The input contains different whitespaces and to make it more readable, we replace spaces with "⎵", tabs with "⇥", and newlines with "↵". Note that the regular space char has a length of 1 and contains one byte "0x20" but the UTF-8 symbol "⎵" is represented as three bytes "0xe2 0x8e 0xb5", so it has a length of 3. Similarly, tabs "⇥" have the length of 3 and so do newlines as "↵" has the length of 3.
passport ✓ sun cream ✗ swimming suit ✓ money ✓ medicine ✗ camera ✗ mobile phone ✓ a good book ✗ toothbrush ✓
176:passport⇥✓↵sun⎵cream⇥✗↵swimming⎵suit⇥✓↵money⇥⇥✓↵medicine⇥✗↵camera⇥⇥✗↵mobile⎵phone⇥✓↵a⎵good⎵book⇥✗↵toothbrush⇥✓,
Required options
These options will be used automatically if you select this example.
Prefix the output by the length of the string.
Convert each word to a netstring individually.
Convert each line to a netstring individually.
Recursively encode the output string the second time.
Remove spaces that appear more than once.
Visualize line feeds as "↵". (Works only when multi-line is off.)
Visualize spaces as "⎵".
Visualize tabs as "⇥".
Pro tips Master online string tools
You can pass input to this tool via ?input query argument and it will automatically compute output. Here's how to type it in your browser's address bar. Click to try!
https://onlinestringtools.com/convert-string-to-netstring?input=every%20moment%20matters&string-form=true&encode-words=true&multi-line=false&double-protection=false&skip-repeated-spaces=false&beautify-newlines=false&beautify-spaces=false&beautify-tabs=false
All string tools
Didn't find the tool you were looking for? Let us know what tool we are missing and we'll build it!
Quickly URL-escape a string.
Quickly URL-unescape a string.
Quickly convert a string to HTML entities.
Quickly convert HTML entities to a string.
Quickly convert a string to base64 encoding.
Quickly decode a base64-encoded string.
Quickly construct a netstring from a regular string.
Quickly decode a netstring and output its contents.
Quickly quote a string with backslashes.
Quickly un-quote a backslash-quoted string.
Quickly generate a random string.
Quickly generate a string from the given regular expression.
Quickly extract all regular expression matches from a string.
Quickly check if a string matches a regular expression.
Quickly extract a fragment of a string.
Quickly create an image from a string.
Quickly apply printf (or sprintf) on strings.
Quickly split a string into pieces.
Quickly join strings together.
Quickly filter lines that match a pattern in a multi-line string.
Quickly duplicate a string multiple times.
Quickly reverse a string.
Quickly find and replace parts of a string with a new string.
Quickly truncate a string to the given length.
Quickly left-trim and right-trim a string.
Quickly pad a string on the left.
Quickly pad a string on the right.
Quickly align a string to the right.
Quickly center a string.
Quickly sort a list of strings in alphabetical, alphanumerical or numerical order.
Quickly rotate a string to the left or to the right.
Quickly convert a string to ROT13.
Quickly convert a string to ROT47.
Quickly transpose a string.
Quickly fetch a part of a string.
Quickly add a prefix to a string.
Quickly add a suffix to a string.
Quickly convert spaces to newlines in a string.
Quickly convert newlines to spaces in a string.
Quickly convert spaces to tabs in a string.
Quickly convert tabs to spaces in a string.
Quickly remove empty lines from a string.
Quickly remove spaces, tabs, and newlines from a string.
Quickly remove dots, commas, and other marks from a string.
Quickly calculate a string's length.
Quickly calculate the number of newlines in a string.
Quickly convert a string to a binary string.
Quickly convert a binary string to a string.
Quickly convert a string to an octal string.
Quickly convert an octal string to a string.
Quickly convert a string to a decimal string.
Quickly convert a decimal string to a string.
Quickly convert a string to a hexadecimal string.
Quickly convert a hexadecimal string to a string.
Quickly convert a string to ASCII codes.
Quickly convert ASCII codes to a string.
Quickly change the case of characters in a string.
Quickly convert a string to uppercase.
Quickly convert a string to lowercase.
Quickly randomize the case of each letter in a string.
Quickly invert string's case.
Quickly extract string data from a JSON data structure.
Quickly convert a string to a JSON string.
Quickly convert a JSON stringified string to a regular string.
Quickly extract all string data from a HTML page.
Quickly extract all string data from an XML document.
Quickly convert a CSV file to evenly aligned columns of space-separated strings.
Quickly convert strings to a proper CSV file.
Quickly extract all string data from a BBCode markup.
Quickly convert a string to Morse code.
Quickly convert Morse code to a string.
Quickly create a palindrome from a string.
Quickly check if a string is a palindrome.
Quickly generate all monograms of a string.
Quickly generate all digrams of a string.
Coming soon These string tools are on the way
Replace Multiple Strings
Replace a set of strings with a new set.
Title-case a String
Convert a string to a title with proper titlecase.
Capitalize Words in a String
Convert the first letter of every word in a string to uppercase.
Justify a String
Stretch out a string and align it along the left and right margins.
Format a Multi-line String
Format and align a multi-line string.
Number of Letters in a String
Find how many letters there are in a string.
Number of Words in a String
Find how many words there are in a string.
Number of Lines in a String
Find how many lines there are in a multi-line string.
Number of Paragraphs in a String
Find how many paragraphs there are in a multi-line string.
Sort Words in a String
Sort all words in a string alphabetically.
Sort a Numeric String
Sort a string that contains only numbers.
Reverse Words in a String
Reverse the order of all words in a string.
Reverse Sentences in a String
Reverse the order of all sentences in a string.
String Frequency Analysis
Find most frequent letters, words and phrases in a string.
Create String Mnemonic
Generate a mnemonic for words in a string.
Number a Multi-line String
Add line numbers to a multi-line string.
Wrap a String
Wrap strings to the given line length.
Chunkify a String
Split a string into chunks of certain length.
Divide a String into Syllables
Find syllables in a string.
Shuffle Words in a String
Shuffle the order of all words in a string.
Extract Emails from a String
Find and extract all email addresses from a string.
Extract URLs from a String
Find and extract all web addresses from a string.
Zigzagify a String
Make a string go in zigzags.
Extract Numbers from a String
Find and extract all numbers from a string.
Generate String Statistics
Analyze string's complexity.
Convert a String to Punycode
Encode a string to punycode.
Convert Punycode to a String
Decode a string from punycode.
QP-encode a String
Convert a string to quoted-printable encoding.
QP-decode a String
Convert quoted-printable encoded data to a string.
Base32-encode a String
Encode a string to base32.
Base32-decode a String
Decode a string from base32.
Base58-encode a String
Encode a string to base58.
Base58-decode a String
Decode a string from base58.
Base85-encode a String
Encode a string to Ascii85.
Base85-decode a String
Decode a string from Ascii85.
UTF8-encode a String
Encode a string to UTF8.
UTF8-decode a String
Decode a string from UTF8.
UTF16-encode a String
Encode a string to UTF16.
UTF16-decode a String
Decode a string from UTF16.
UTF32-encode a String
Encode a string to UTF32.
UTF32-decode a String
Decode a string from UTF32.
IDN-encode a String
Encode a string to IDN.
IDN-decode a String
Decode a string from IDN encoding.
Uuencode a String
Convert a string to Unix-to-Unix encoding.
Uudecode a String
Convert Unix-to-Unix data to a string.
Xxencode a String
Convert a string to Xxencoding.
Xxdecode a String
Convert an Xxencoded string to a regular string.
HTML-strip a String
Strip all HTML tags from a string.
Remove Accent Characters
Remove all diacritical signs from a string.
Remove Duplicate Spaces
Normalize string spacing and remove all duplicate spaces.
Diff Two Strings
Visualy compare and find differences between two strings.
String Levenshtein Distance
Calculate Levenshtein distance between two strings.
Rewrite a String
A tiny string rewriting system.
Generate a Zalgo String
Convert a string to Unicode mess.
Generate String Typos
Create a list of all possible string typos.
Mirror a String
Generate a mirror copy of a string.
Generate Trigrams
Generate all 3-grams of a string.
Generate all N-grams
Generate all ngrams of a string.
Generate N-skip-M-grams
Generate n-skip-m-grams of a string.
Tokenize a String
Create a list of tokens from a string.
Lemmatize a String
Lemmatize all words in a string.
Stem a String
Do stemming of all words in a string.
Grep a String
Extract fragments that match a regular expression in a string.
Head a String
Split a string into fragments and extract the beginning parts.
Tail a String
Split a string into fragments and extract the ending parts.
Convert a String to an Array
Create an array of characters from a string.
Convert a String to Integers
Split a string into characters and return their integer values.
Quote a String
Wrap a string in a pair of quotes.
Unquote a String
Remove quotes around a string.
Shift a String
Shift characters in a string to the left or right.
Slugify a String
Create a SEO-friendly URL from a string.
Create a String Cloud
Create a word cloud from all words in a string.