Yukkuri Games

String Lerp

String Lerp is a JavaScript module to interpolate (lerp, blend, tween) between two string values, that is, progressively turn one string into another. It uses Levenshtein distance measurements along with other heuristics to try to blend between two strings as naturally as possible.

Not really sure what that means? Try it out.

Try a different string pair


In a browser, use

<script type="text/javascript" src="string-lerp.js"></script>

In Node.js and other non-browser environments,

var stringLerp = require("./string-lerp")


var result = stringLerp.lerp(source, target, amount);
    // `source' is the string to start with
    // `target' is the string to finish with
    // `amount' is an amount to edit the strings, between 0 and 1,
    //          e.g. 0.23 = 23% from source to target

The internal diff and patch routines are also exposed, as diffLerp is too slow for very long strings unless you compute and store the diff list ahead of time.