try { return JSON.parse(value); } catch(e) { return value; } This is quite interesting, but caution that it is IE8+ dependent.