You can use this : http://jsbeautifier.org/
But it depends on the minify method you are using, this one only formats the code, it doesn't change variable names, nor uncompress base62 encoding.
Chrome developer tools has this feature built-in. Bring up the developer tools (pressing F12 is one way), in the Sources tab, the bottom left bar has a set of icons. The "{}" icon is "Pretty print" and does this conversion on demand.
UPDATE: IE9 "F12 developer tools" also has a "Format JavaScript" feature in the Script tab under the Tools icon there. (see Tip #4 in F12 The best kept web debugging secret)
(function () { /* Say hello. */ var x = 'Hello!'; print(x); }).toSource()
将转换为字符串:
function () {
var x = "Hello!";
print(x);
}
PS:这不是一个“在线工具”,但所有有关一般美容技术的问题都作为此问题的重复项而关闭。
In Firefox, SpiderMonkey and Rhino you can wrap any code into an anonymous function and call its toSource method, which will give you a nicely formatted source of the function.
toSource also strips comments.
E. g.:
(function () { /* Say hello. */ var x = 'Hello!'; print(x); }).toSource()
Will be converted to a string:
function () {
var x = "Hello!";
print(x);
}
P. S.: It's not an "online tool", but all questions about general beautifying techniques are closed as duplicates of this one.
As an alternative (since I didn't know about jsbeautifier.org until now), I have used a bookmarklet that reenabled the decode button in Dean Edward's Packer.
Despite its miles-away-from-being-pretty interface, JSPretty is a good, free and online tool for making javascript source codes human-readable. You can enforce your preferred type of indentation and it can also detect obfuscation.
发布评论
评论(17)
您可以使用这个:http://jsbeautifier.org/
但这取决于您使用的 minify 方法,该方法仅格式化代码,它不会更改变量名称,也不会解压缩 base62 编码。
编辑:事实上,它可以解压“打包”脚本(用 Dean Edward 的打包器打包:http://dean.edwards。名称/打包者/)
You can use this : http://jsbeautifier.org/
But it depends on the minify method you are using, this one only formats the code, it doesn't change variable names, nor uncompress base62 encoding.
edit: in fact it can unpack "packed" scripts (packed with Dean Edward's packer : http://dean.edwards.name/packer/)
Chrome 开发者工具内置了此功能。 打开开发者工具(按 F12 是一种方法),在 Sources 选项卡中,左下栏有一组图标。 “{}”图标是“Pretty print”,并根据需要进行此转换。
更新:IE9“F12 开发人员工具”在“工具”图标下的“脚本”选项卡中还具有“格式化 JavaScript”功能。 (请参阅 F12 最好的 Web 调试秘密)
< img src="https://i.sstatic.net/wIMSh.jpg" alt="在此处输入图像描述">
Chrome developer tools has this feature built-in. Bring up the developer tools (pressing F12 is one way), in the Sources tab, the bottom left bar has a set of icons. The "{}" icon is "Pretty print" and does this conversion on demand.
UPDATE: IE9 "F12 developer tools" also has a "Format JavaScript" feature in the Script tab under the Tools icon there. (see Tip #4 in F12 The best kept web debugging secret)
知道了! JSBeautifier 正是这样做的,您甚至可以选择自动格式化。
Got it! JSBeautifier does exactly this, and you even have options for the auto-formatting.
你不能只使用 javascript 格式化程序吗(http://javascript.about.com/library/blformat .htm)?
Can't you just use a javascript formatter (http://javascript.about.com/library/blformat.htm) ?
在 Firefox、SpiderMonkey 和 Rhino 中,您可以将任何代码包装到匿名函数中并调用其
toSource
方法,它将为您提供格式良好的函数源代码。toSource
也会删除注释。E. g.:
将转换为字符串:
PS:这不是一个“在线工具”,但所有有关一般美容技术的问题都作为此问题的重复项而关闭。
In Firefox, SpiderMonkey and Rhino you can wrap any code into an anonymous function and call its
toSource
method, which will give you a nicely formatted source of the function.toSource
also strips comments.E. g.:
Will be converted to a string:
P. S.: It's not an "online tool", but all questions about general beautifying techniques are closed as duplicates of this one.
如果您有 Mac 和 TextMate - 格式化 Javascript 的一个简单替代方法是:
If you have a Mac and TextMate - An easy alternative for formatting Javascript is:
大多数 IDE 还提供自动格式化功能。 例如,在 NetBeans 中,只需按 CTRL+K。
Most of the IDEs also offer auto-formatting features. For example in NetBeans, just press CTRL+K.
作为替代方案(因为直到现在我还不知道 jsbeautifier.org),我使用了一个小书签来重新启用 Dean Edward's Packer 中的解码按钮。
我在此处找到了说明和书签。
这是书签(以防网站关闭)
As an alternative (since I didn't know about jsbeautifier.org until now), I have used a bookmarklet that reenabled the decode button in Dean Edward's Packer.
I found the instructions and bookmarklet here.
here is the bookmarklet (in case the site is down)
我不确定你是否需要源代码。 http://www.blackbeltcoder.com/Resources/JSFormatter.aspx 上有一个免费的在线 JavaScript 格式化程序。
I'm not sure if you need source code. There is a free online JavaScript formatter at http://www.blackbeltcoder.com/Resources/JSFormatter.aspx.
尝试这个,带有代码着色:
http://labs.swelen.com/tools/javascript/beauty.html< /a>
Try this one, with code coloration:
http://labs.swelen.com/tools/javascript/beauty.html
点击这些链接即可进行 JS 去矿化。 它将作为扩展安装在 FF 上,帮助您在运行时调试 js。
https://addons.mozilla.org/ en-US/firefox/addon/javascript-deminifier/eula/141018?src=dp-btn-primary
click on these link for JS deminification. That will install on FF as extension that help you in debugging js at runtime.
https://addons.mozilla.org/en-US/firefox/addon/javascript-deminifier/eula/141018?src=dp-btn-primary
与 Stone 的答案类似,但对于 Windows/.NET 开发人员:
如果您有 Visual Studio 和 ReSharper - 一个简单的替代方案格式化 Javascript 的方法是:
Similar to Stone's answer, but for Windows/.NET developers:
If you have Visual Studio and ReSharper - An easy alternative for formatting Javascript is:
尽管JSPretty的界面与pretty相去甚远,但它是一个很好的、免费的在线工具,用于制作javascript源代码是人类可读的。 您可以强制执行您喜欢的缩进类型,它还可以检测混淆。
Despite its miles-away-from-being-pretty interface, JSPretty is a good, free and online tool for making javascript source codes human-readable. You can enforce your preferred type of indentation and it can also detect obfuscation.
如果是 JS 的话,使用 Firefox 的可能性就更大了。 如果它的 Firefox 插件是为了救援。 下面的一项特别有用。
https://addons.mozilla.org/en-US/firefox/addon/凤凰/
If one is in JS possibility of using Firefox is more. And if its Firefox add on is for rescue. Following one is particularly useful.
https://addons.mozilla.org/en-US/firefox/addon/phoenix/
Pretty Diff 将以符合以下的方式美化(漂亮打印)JavaScript JSLint 和 JSHint > 空白算法。
Pretty Diff will beautify (pretty print) JavaScript in a way that conforms to JSLint and JSHint white space algorithms.
我对 jsbeautifier.org 的输出不太满意,所以我做了更多搜索并找到了这个网站: http://www.centralinternet.com.br/javascript-beautifier
对我来说效果非常好。
Wasn't really happy with the output of jsbeautifier.org for what I was putting in, so I did some more searching and found this site: http://www.centralinternet.com.br/javascript-beautifier
Worked extremely well for me.
http://unminify.appspot.com/
用于 unminify javascript 和 json 的好工具
http://unminify.appspot.com/
Great tools for unminify javascript and json