{"id":14981092,"url":"https://github.com/traut/prettier-elastic-query","last_synced_at":"2025-10-29T04:31:44.790Z","repository":{"id":33039849,"uuid":"144978345","full_name":"traut/prettier-elastic-query","owner":"traut","description":"Elasticsearch query formatter and highlighter. Pretty print for Elasticsearch queries","archived":false,"fork":false,"pushed_at":"2022-12-03T03:04:28.000Z","size":1639,"stargazers_count":5,"open_issues_count":7,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-01T22:01:54.347Z","etag":null,"topics":["elastic","elasticsearch","elasticsearch-queries","highlight-query","ohm","prettifier","prism","query-formatting"],"latest_commit_sha":null,"homepage":"https://traut.github.io/prettier-elastic-query/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/traut.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-16T11:24:52.000Z","updated_at":"2022-01-27T09:18:57.000Z","dependencies_parsed_at":"2023-01-14T23:09:32.253Z","dependency_job_id":null,"html_url":"https://github.com/traut/prettier-elastic-query","commit_stats":null,"previous_names":["traut/prettier-es"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/traut%2Fprettier-elastic-query","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/traut%2Fprettier-elastic-query/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/traut%2Fprettier-elastic-query/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/traut%2Fprettier-elastic-query/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/traut","download_url":"https://codeload.github.com/traut/prettier-elastic-query/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238768422,"owners_count":19527197,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elastic","elasticsearch","elasticsearch-queries","highlight-query","ohm","prettifier","prism","query-formatting"],"created_at":"2024-09-24T14:02:54.504Z","updated_at":"2025-10-29T04:31:39.486Z","avatar_url":"https://github.com/traut.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"prettier-elastic-query\n======================\n\n[![npm version](https://badge.fury.io/js/prettier-elastic-query.svg)](https://badge.fury.io/js/prettier-elastic-query)\n\n[prettier-elastic-query](https://github.com/traut/prettier-elastic-query) is a library for formatting and highlighting Elasticsearch queries.\n\nprettier-elastic-query uses [Ohm](https://ohmlang.github.io/) parser to parse the query and [Prism](https://prismjs.com/) for highlighting it.\nSee [demo page](https://traut.github.io/prettier-elastic-query/dist/demos/index.html) for examples or try [live editor](https://traut.github.io/prettier-elastic-query/dist/demos/editor.html) with your own query.\n\n\nGetting Started\n---------------\n### Installation\n\nIf you are using Node.js, you can just install the `prettier-elastic-query` package using [npm](http://npmjs.org):\n\n    npm install prettier-elastic-query\n\nThis will install prettier-elastic-query in the local `node_modules` folder. Use `require` to access it from a Node script:\n\n```js\nvar prettier = require('prettier-elastic-query');\n```\n\nIf you want to use prettier-elastic-query in a browser, you can download [prettier-elastic-query.min.js](https://raw.githubusercontent.com/traut/prettier-elastic-query/master/dist/prettier-elastic-query.min.js) and reference it in your HTML file.\n\n```html\n\u003cscript src=\"prettier-elastic-query.min.js\" type=\"text/javascript\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n    console.info(PrettierEs.prettify(\"query text\", 80));\n\u003c/script\u003e\n```\n\nSee [demo page source](https://github.com/traut/prettier-elastic-query/blob/master/dist/demos/index.html) for usage example.\n\nAPI reference\n-------------\n\n`prettify(query, maxWidth, style)` - format and highlight ES query. Calls `format()` and `highlight()` functions inside;\n\n`prettifyElement(elementId, showErrors, maxWidth, errorCss)` - formats and highlights ES query inplace inside HTML element. `showErrors` - boolean indicating if error information should be rendered, false by default. `errorCss` class to be used in error message formatting;\n\n`format(query, maxWidth, style)` - format ES query, fitting it in `maxWidth` characters per line and following provided style. Possible style options are `lisp` and `simple`, with `lisp` being used if no style argument provided;\n\n`highlight(query)` - highlight query with [Prism](https://prismjs.com/). prettier-elastic-query build provides default Prism css theme. You can use any Prism theme, just include theme's css style file in your html file;\n\n`parse(query)` - parse query and return syntax tree. This function throws an error if parsing fails. Used by `format()` function;\n\n`extendHighlighter(options)` - takes `options` dictionary and extends Prism highlighter. At the moment only `keywords` key in `options` is supported and is used to extend `keyword` Prism language configuration;\n\n`markErrorInQuery(query, error, cssClass)` - inserts `\u003cu\u003e` element around offending character in the query. `error` here is an instance of the error thrown by `format` function.\n\n`prism` - Prism object;\n\n`grammar` - Ohm grammar.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftraut%2Fprettier-elastic-query","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftraut%2Fprettier-elastic-query","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftraut%2Fprettier-elastic-query/lists"}