Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
a simple gibberish / random text generator using a markov chain.
branch: master

Fix tabs in readme

latest commit 940bf83288
Brian Hicks authored
Failed to load latest commit information.
sample Initial code + samples Fix tabs in readme
json2.js Initial code + samples
markov.js Initial code + samples

Markov Text Generator


Because to understand markov chains I needed to hack something together. And to be honest, it produces some pretty interesting little stories, given the right input.


After including json2.js and markov.js in your page...

var test = new markov(text, type, regex);

The text can be anything you so desire. The type should be "string" or "json". And the regex should always be global. All matches are used.


to generate a phrase of a given length:


to see the object containing the data:;

to get the JSON generated by JSON2.js of the data:


A warning though, you probably only want to use the JSON for making things a bit faster on the processing end with long text, as the JSON tends to be an order of magnitude greater in file size than the input text.


This is all open source, you can use it however you like. Especially to learn.

That said, I would enjoy it if you would send me a sample to work produced by this.

Oh, and JSON2.js isn't mine, the source can be found at

Something went wrong with that request. Please try again.