diff --git a/locales/en.yml b/locales/en.yml
index e56d8a72..1aa93cec 100644
--- a/locales/en.yml
+++ b/locales/en.yml
@@ -203,7 +203,15 @@ tools:
json-to-yaml-converter:
title: JSON to YAML converter
- description: Simply convert JSON to YAML with this online live converter.
+ description: Simply convert JSON to YAML with this live online converter.
+
+ json-to-javascript:
+ title: JSON to JS converter
+ description: Simply convert JSON to Javascript object with this live online converter.
+
+ javascript-to-json:
+ title: JS to JSON converter
+ description: Simply convert Javascript object to JSON with this live online converter.
url-parser:
title: URL parser
diff --git a/locales/zh.yml b/locales/zh.yml
index 50dd626f..ea727e7a 100644
--- a/locales/zh.yml
+++ b/locales/zh.yml
@@ -198,6 +198,14 @@ tools:
title: JSON到YAML转换器
description: 在线转换将JSON转换为YAML。
+ json-to-javascript:
+ title: JSON 到 JS 转换器
+ description: 使用此在线转换器将 JSON 转换为 Javascript 对象。
+
+ javascript-to-json:
+ title: JS 到 JSON 转换器
+ description: 使用此在线转换器将 Javascript 对象转换为 JSON。
+
url-parser:
title: Url分析器
description: 解析url字符串以获取所有不同的部分(协议、来源、参数、端口、用户名密码…)
diff --git a/src/components/TextareaCopyable.vue b/src/components/TextareaCopyable.vue
index a0961f1b..ed0f2501 100644
--- a/src/components/TextareaCopyable.vue
+++ b/src/components/TextareaCopyable.vue
@@ -2,6 +2,7 @@
import { Copy } from '@vicons/tabler';
import { useElementSize } from '@vueuse/core';
import hljs from 'highlight.js/lib/core';
+import javascriptHljs from 'highlight.js/lib/languages/javascript';
import jsonHljs from 'highlight.js/lib/languages/json';
import sqlHljs from 'highlight.js/lib/languages/sql';
import xmlHljs from 'highlight.js/lib/languages/xml';
@@ -37,6 +38,7 @@ const props = withDefaults(
downloadButtonText: 'Download',
},
);
+hljs.registerLanguage('javascript', javascriptHljs);
hljs.registerLanguage('sql', sqlHljs);
hljs.registerLanguage('json', jsonHljs);
hljs.registerLanguage('html', xmlHljs);
diff --git a/src/tools/index.ts b/src/tools/index.ts
index ffaa8443..26047437 100644
--- a/src/tools/index.ts
+++ b/src/tools/index.ts
@@ -164,6 +164,8 @@ import { tool as jsonDiff } from './json-diff';
import { tool as ipv4RangeExpander } from './ipv4-range-expander';
import { tool as httpStatusCodes } from './http-status-codes';
import { tool as yamlToJson } from './yaml-to-json-converter';
+import { tool as javascriptToJson } from './javascript-to-json';
+import { tool as jsonToJavascript } from './json-to-javascript';
import { tool as jsonToYaml } from './json-to-yaml-converter';
import { tool as ipv6UlaGenerator } from './ipv6-ula-generator';
import { tool as ipv4AddressConverter } from './ipv4-address-converter';
@@ -289,6 +291,8 @@ export const toolsByCategory: ToolCategory[] = [
textToUnicodeNames,
yamlToJson,
yamlToToml,
+ javascriptToJson,
+ jsonToJavascript,
jsonToYaml,
jsonToToml,
listConverter,
diff --git a/src/tools/javascript-to-json/index.ts b/src/tools/javascript-to-json/index.ts
new file mode 100644
index 00000000..4181636f
--- /dev/null
+++ b/src/tools/javascript-to-json/index.ts
@@ -0,0 +1,13 @@
+import { Braces } from '@vicons/tabler';
+import { defineTool } from '../tool';
+import { translate } from '@/plugins/i18n.plugin';
+
+export const tool = defineTool({
+ name: translate('tools.javascript-to-json.title'),
+ path: '/javascript-to-json',
+ description: translate('tools.javascript-to-json.description'),
+ keywords: ['javascript', 'to', 'json'],
+ component: () => import('./javascript-to-json.vue'),
+ icon: Braces,
+ createdAt: new Date('2024-03-29'),
+});
diff --git a/src/tools/javascript-to-json/javascript-to-json.vue b/src/tools/javascript-to-json/javascript-to-json.vue
new file mode 100644
index 00000000..b563401d
--- /dev/null
+++ b/src/tools/javascript-to-json/javascript-to-json.vue
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
diff --git a/src/tools/json-to-javascript/index.ts b/src/tools/json-to-javascript/index.ts
new file mode 100644
index 00000000..0f61192e
--- /dev/null
+++ b/src/tools/json-to-javascript/index.ts
@@ -0,0 +1,13 @@
+import { Braces } from '@vicons/tabler';
+import { defineTool } from '../tool';
+import { translate } from '@/plugins/i18n.plugin';
+
+export const tool = defineTool({
+ name: translate('tools.json-to-javascript.title'),
+ path: '/json-to-javascript',
+ description: translate('tools.json-to-javascript.description'),
+ keywords: ['json', 'to', 'javascript'],
+ component: () => import('./json-to-javascript.vue'),
+ icon: Braces,
+ createdAt: new Date('2024-03-29'),
+});
diff --git a/src/tools/json-to-javascript/json-to-javascript.vue b/src/tools/json-to-javascript/json-to-javascript.vue
new file mode 100644
index 00000000..7318d5f2
--- /dev/null
+++ b/src/tools/json-to-javascript/json-to-javascript.vue
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+