var str = 'a.b.c.d'; var o = str.split('.').reduceRight(function(a, b){var o = {}; o[b] = a; return o;}); alert(JSON.stringify(o));