epgSoft

Text Converter

Convert text, data, or code between formats.

About Text Converter

If you work with data or code long enough, eventually you'll run into the need to convert between formats. Maybe it's converting raw data into a standard format such as CSV or a programming language array format, converting array data between two different languages, or even converting HTML code from one framework to another.

Sure, there are many ways to tackle this today. You could take the brute force approach and manually edit the data or code, but this is error prone, tedious, and very time consuming. You could use search and replace in a text editor, but this only works in the simplest of cases. Some text editors provide the ability to use recorded macros, and this used to be the approach I used, but how many times have you made a mistake half way through the recording and have had to start all over again?

I've been thinking that there has to be a better way to address this for a while, and recently when I had to convert some HTML code from Google MDL to MDC, I decided to take the time to take a stab at writing a tool. I'm pretty happy with the result. Does it handle every scenario? No, as there are so many nuances around conversions that it's hard to address them all. But I think it does handle many of the common scenarios that knowledge workers and software developers run into (see below for some examples). And this is just my first pass at this tool. I will continue to enhance and even rethink this tool as I use it myself going forward. If you have any suggestions as to how to improve it or even a completely different approach, please let me know your thoughts!

How to use Text Converter

  1. Enter the text you'd like to convert into the Input Text area. The data should be homogenous, meaning all of it should be in the same format. Don't include header lines or other text or code that isn't part of the data.
  2. You will now create an input template. An input template specifies what makes up an input data item, and what data will be extracted from it when creating the output data. Select how many lines make up one data item. See the examples section below for more details about multiline input templates.
  3. Next you need to break up the input template into multiple pieces or snippets so that you can extract parts of the data for use in the output template. You do this by specifying delimiters that are used to separate the data. You can select common ones such as Space and Tabs, and you can enter one or more characters under Additional Delimiters. The results will be displayed in the Input Template area, with the data snippets that can be used in the output template highlighted.
  4. Now you can create your output template. Your output template will be applied repeatedly to each input line (or lines) in your input data. It can consist of static text as well as data extracted from the input data via the input template. To place data from the input template in your output template, just click on the highlighted data in your input template.
  5. Your output text and can be found in the Output Text area. From here you can either copy the output text to the clipboard by clicking the Copy button, or save it to a file by clicking the Save button. The saved file will be called "output.txt" and it will be placed in your Downloads directory.
Click the help About / Help toolbar button or menu item to view this page again.

Examples of how to use Text Converter

Sometimes it's easier to show examples of how to use something rather than trying to describe it, and this is one of those cases. The following section shows three common examples of using Text Converter.

Converting data

Suppose you want to convert the following raw data into CSV format:

Enter Input Text

Enter the raw data as Input Text:

Year: 2018
Make: Toyota
Model: Rav4
Year: 2017
Make: Honda
Model: CRV
Year: 2019
Make: Chevrolet
Model: Equinox

Generate Input Template

Since each entry in the input text takes up three lines, set Number of lines to 3.

And since we want to only keep the values, select the Space checkbox and enter the colon character (":") as an Additional Delimiter.

This is what your resulting Input Template should look like:

Year: 2018
Make: Toyota
Model: Rav4

Create Output Template

Create an Output Template that represents a line in the CSV file. Click on the highlighted values in the Input Template to place them in the Output Template. Enter commas between each value. This is what your resulting Output Template should look like:

2018,Toyota,Rav4

Output Text

The Output Text area now contains the fully converted CSV output:

2018,Toyota,Rav4
2017,Honda,CRV
2019,Chevrolet,Equinox

Converting data to code

Now suppose you instead want to convert the raw data from the first example into an array of Javscript objects:

Create Output Template

Create an Output Template that represents a Javascript object definition as an array element. Click on the highlighted keys and values in the Input Template to place them in the Output Template. Enter other text needed to produce valid Javascript syntax. This is what your resulting Output Template should look like:

{Year: 2018, Make: "Toyota", Model: "Rav4"},

Output Text

The Output Text area now contains the fully converted Javascript object array. You only need to wrap it with the array declaration and remove the comma from the end of the last line.

{Year: 2018, Make: "Toyota", Model: "Rav4"},
{Year: 2017, Make: "Honda", Model: "CRV"},
{Year: 2019, Make: "Chevrolet", Model: "Equinox"},

Converting code

Suppose you have a bunch of HTML text fields that were originally created using Google's MDL framework, but now you want to upgrade them to the MDC framework:

Enter Input Text

Enter the MDL textfield code as Input Text:

<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
  <input class="mdl-textfield__input" type="text" id="firstName">
  <label class="mdl-textfield__label" for="firstName">First Name</label>
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
  <input class="mdl-textfield__input" type="text" id="lastName">
  <label class="mdl-textfield__label" for="lastName">Last Name</label>
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
  <input class="mdl-textfield__input" type="text" id="email">
  <label class="mdl-textfield__label" for="email">Email</label>
</div>

Generate Input Template

Since each entry in the MDL textfield code takes up four lines, set Number of lines to 4.

Since we want to only keep the ids and labels, enter the double quote, less than, and greater than characters ('"<>') as Additional Delimeters.

This is what your resulting Input Template should look like:

<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
  <input class="mdl-textfield__input" type="text" id="firstName">
  <label class="mdl-textfield__label" for="firstName">First Name</label>
</div>

Create Output Template

Create an Output Template that represents an MDC textfield. Click on the highlighted ids and labels in the Input Template to place them in the Output Template where needed. This is what your resulting Output Template should look like:

<label class="mdc-text-field mdc-text-field--filled">
  <span class="mdc-text-field__ripple"></span>
  <input class="mdc-text-field__input" type="text" id="firstName" aria-labelledby="firstNameLabel">
  <span class="mdc-floating-label" id="firstNameLabel">First Name</span>
  <span class="mdc-line-ripple"></span>
</label>

Output Text

The Output Text area now contains the fully converted MDC textfield code:

<label class="mdc-text-field mdc-text-field--filled">
  <span class="mdc-text-field__ripple"></span>
  <input class="mdc-text-field__input" type="text" id="firstName" aria-labelledby="firstNameLabel">
  <span class="mdc-floating-label" id="firstNameLabel">First Name</span>
  <span class="mdc-line-ripple"></span>
</label>
<label class="mdc-text-field mdc-text-field--filled">
  <span class="mdc-text-field__ripple"></span>
  <input class="mdc-text-field__input" type="text" id="lastName" aria-labelledby="lastNameLabel">
  <span class="mdc-floating-label" id="lastNameLabel">Last Name</span>
  <span class="mdc-line-ripple"></span>
</label>
<label class="mdc-text-field mdc-text-field--filled">
  <span class="mdc-text-field__ripple"></span>
  <input class="mdc-text-field__input" type="text" id="email" aria-labelledby="emailLabel">
  <span class="mdc-floating-label" id="emailLabel">Email</span>
  <span class="mdc-line-ripple"></span>
</label>

Feedback on Text Converter

I value your feedback! Contact me with any issues you find, or any suggestions you may have to improve this app. Thank you in advance for your help!

Get started with Text Converter

To get started with Text Converter, click the Convert Text button below.