Strings entered into this website for the purpose of concatenation are not persisted or saved. However, this site uses cookies to store your preferences. If you wish to opt out of cookies, you may still use this website, however your preferences will not be stored from session to session. You may always return to this section to change your cookie preference. Clicking "Save Setting" will cause the page to reload.

Wouldn't it be great to just paste your massive SQL query or other large block of text somewhere and then have a concatenated string or StringBuilder object magically form around it?
(Answer: Yes it would be) Now you can automatically create concatenated strings and automatically create StringBuilder objects. BuildMyString.com will take whatever text you input, escape it, and output the results. If you find an issue or want to offer a change or enhancement idea, note it in the comments. Please keep your suggestions coming!!!! Let's turn this string escaper into Skynet!
BMS will remember your settings if you turn on cookies at the upper left of the site. And no, your strings are not logged or saved in any way - I have no desire to know what people type into this thing.

If you're using IE and this page is broken, see this to fix it. It's typically one of the first two issues.

Note that if you select the option to preserve blank lines AND any of the options that include additional characters at the end of each line, the output will append these characters to your blank lines as well.

If you're outputting text to an HTML doc, you can select this option to have a <br> appended at the end of each line of the input:

StringBuilder sb = new StringBuilder();

sb.append("Four score and seven years ago<br>");
sb.append("our fathers brought forth on this continent,<br>");
sb.append("a new nation, conceived in Liberty,<br>");
sb.append("and dedicated to the proposition that<br>");
sb.append("all men are created equal.<br>");

When inputting multiple lines of text, you might be expecting the words to seperate properly at the line breaks:

Four score and seven years ago
our fathers brought forth on this continent,
a new nation, conceived in Liberty,
and dedicated to the proposition that
all men are created equal.

However, most multi line text will terminate right after the last character of the line creating an unexpected result in the output:

StringBuilder sb = new StringBuilder();

sb.Append("Four score and seven years ago");
sb.Append("our fathers brought forth on this continent,");
sb.Append("a new nation, conceived in Liberty,");
sb.Append("and dedicated to the proposition that");
sb.Append("all men are created equal.");

By checking this box, a space will be appended to the end of each line:

StringBuilder sb = new StringBuilder();

sb.Append("Four score and seven years ago ");
sb.Append("our fathers brought forth on this continent, ");
sb.Append("a new nation, conceived in Liberty, ");
sb.Append("and dedicated to the proposition that ");
sb.Append("all men are created equal. ");

You may need to append something custom to the end of each line. You can enter a custom suffix here.
(Note if you use a custom suffix, it will NOT be escaped, you must do that yourself.)

Text::StringBuilder^ sb = gcnew Text::StringBuilder;

sb->Append("Four score and seven years ago\n");
sb->Append("our fathers brought forth on this continent,\n");
sb->Append("a new nation, conceived in Liberty,\n");
sb->Append("and dedicated to the proposition that\n");
sb->Append("all men are created equal.\n");

For C#, VB.NET, and C++, select this option to use AppendLine instead of Append for the Stringbuilder object.
AppendLine will add the default line terminator to the end of each line:
(This option has no effect if the target object is a concatenated string or if the target language is Java)

sb.AppendLine("Four score and seven years ago");
sb.AppendLine("our fathers brought forth on this continent,");

OUTPUT: Four score and seven years ago
our fathers brought forth on this continent,

For a VB.NET concatenated string only, selecting this option will append the VB carriage return constant at the end of each line of the string.
This option only applies if VB.NET is the target language and the target object is a concatenated string.

Strip out any Tabs that are found in the source text. This can be useful to remove unwanted Tabs, but keep in mind anything seperated by a Tab in the source text will no longer be seperated in the output:

If you're outputting text that's not HTML, you can select this option to have \r\n appended at the end of each line of the input.
(This is ignored for VB.Net. There is an option below to append vbCrLF.)

StringBuilder sb = new StringBuilder();

sb.append("Four score and seven years ago\r\n");
sb.append("our fathers brought forth on this continent,\r\n");
sb.append("a new nation, conceived in Liberty,\r\n");
sb.append("and dedicated to the proposition that\r\n");
sb.append("all men are created equal.\r\n");

For a string builder (C# and Java only), selecting this option will build all the appends as a single statement. This will allow the entire string builder to stepped over all at once in the debugger rather than having to step through each line. When debugging with very large string builders, this option will save a lot of time:

Some ground rules: When you select any of the SQL languages, you are getting a concatenated string.
I don't care if you pick 'StringBuilder' or 'None', it's not happening. You are getting a concatenated string.

If you are staring at your ceiling right now yelling at the top of your lungs, "But I want to use a StringBuilder in SQL and you can't stop me!!", well I can stop you and you're a very strange person who shouldn't be writing code to begin with.
Similarly, if you are currently screaming at your cat - "But I use SillySQL! They haven't coded support for SillySQL!?!?!".

Look I can only do so much. I picked 3 common SQL platforms and maybe it's time you upgraded from SillySQL to an industry standard.

Also, some of these options obviously make no sense at all in SQL, but are still available should you wish to use them. Weirdo.

Selecting this option will strip out any carriage returns in your text and return a single line as output. Useful if you if you have a large block of text you'd like as a single line in your code or "pivoting" your string.

You may need to prepend something custom to the beginning of each line. You can enter a custom prefix here.
(Note if you use a custom prefix, it will NOT be escaped, you must do that yourself.)

Text::StringBuilder^ sb = gcnew Text::StringBuilder;

sb->Append("\nFour score and seven years ago");
sb->Append("\nour fathers brought forth on this continent,");
sb->Append("\na new nation, conceived in Liberty,");
sb->Append("\nand dedicated to the proposition that");
sb->Append("\nall men are created equal.");