Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (22 sloc) 2.14 KB
title tags summary date ad
Transforming text
Take a glob of text and apply a series of rules until you have the structured JSON you want.
2019-09-02 11:00:00

Transforming text

During the weekend I spent an hour coding a hacky bit of code and I thought it might help one or two other people so I posted it on Twitter (on Sunday at 10am UK no less) and the response was…surprising. I genuinely thought it would only serve me, but some 120+ retweets and 800+ likes it seems like others found a use too.

Since twitter is rather ephemeral, it made sense to post on my blog (a bonus for all you RSS users 😉).

What is it?


This tool will take a glob of text - an example might some copied data from a browser - and you apply a series of rules to the text until you have the structured data you want.

Transform in action

It might take a bit of playing around with, and frankly the code behind it is fairly messy, but it does the trick.


Before the haters pile on, I absolutely do use command line tools to do string manipulation. I have a whole course on the command line ($80 off with "READERS-DISCOUNT" coupon) and I absolutely did run the original problem through a pipeline of awk, csvjson and jq.

The command line is absolutely fine, but sometimes it's nice to have a webgui to show me what's going on and to perhaps be a little friendlier to a user (though I'm not sure my solution is friendlier - it's fairly bare if I'm frank!).

But that's why. It took me an hour to hack together (you can still see the JS Bin specific runner code in the source) and probably another hour to make nicety tweaks (like grid for layout, memorising URLs, etc).

If you're interested in seeing more of my random micro projects, I tend to put them on - with links to the source where worthwhile.

You can’t perform that action at this time.