SQLite - tool for exporting to "portable" format

Generic Issue

Can anyone recommend a simple and easy tool for exporting from an SQLite format into an Human-readable ascii text format (JSON text file)?

Specific Issue

Is there a way to perform the above action specifically for the bookmark files which are stored for Firefox in the

.mozilla/firefox/${profileDirectory}/bookmarkbackups

in the files that have the form

'bookmarks-2025-08-25_52260_WQLsSaTlkZlCMNx-57DP08bkUaV9-_dKo-sfEdi7Euw=.jsonlz4'

Output Format Control

Also, is there a way to force the output such that there is only one line used per bookmark object? not multiple lines per single bookmark?

2 Likes

Thank you, Pavlos.

Unfortunately, I did have that already ... but it does not open the *.jsonlz4 type files.

When I open one with GVim, the "header-type string" is

  • mozLz40

Turns out that it is not an SQLite DB format as I first imagined it to be! :frowning:

However, I've managed to find a method to decompress the JSON, but it is all a single line of text, not "pretty-printed".

I have my own script for re-structuring "obfuscated" code, so I will see how that turns out and get back to the Community.


Script [USER__CODE__ReFormatPretty.sh]:

#!/bin/bash

###	Hack for attempt at de-obfuscating javascript, css, and similarly formatted files

###	Intended to insert newline at evey semicolon and opening and closing brace
###	Open brace triggers indentation action until closing brace reduces indentation amount

prettify()
{
	awk '{
		gsub(/[;]/,";\n") ;
		gsub(/[{]/,"{\n") ;
		gsub(/[}]/,"\n}\n") ;
		gsub(/[[<][Aa]/,"\n<a") ;
		gsub(/[[<][Dd][Ii][Vv]/,"\n<div") ;
		gsub(/[[<][Uu][Ll]/,"\n<ul") ;
		gsub(/[[<][Ll][Ii]/,"\n<li") ;
		gsub(/[[<][Ss][Pp][Aa][Nn]/,"\n<span") ;
		gsub(/[[<][/][Aa]/,"\n</a") ;
		gsub(/[[<][/][Uu][Ll]/,"\n</ul") ;
		gsub(/[[<][/][Ll][Ii]/,"\n</li") ;
		gsub(/[[<][/][Dd][Ii][Vv]/,"\n</div") ;
		gsub(/[[<][/][Ss][Pp][Aa][Nn]/,"\n</span") ;
		print $0 ;
	}' |
	awk -v dbg=${debug} 'BEGIN{
		indent=0 ;
	}{
		if( $1 == "}" ){
			indent-- ;
			if( indent == -1 ){
				indent++ ;
				if( dbg ==1 ){ print indent, NR | "cat 1>&2" ; } ;
			}else{
				if( dbg ==1 ){ print indent | "cat 1>&2" ; } ;
			} ;
		} ;

		if( indent == 0 ){
			print $0 ;
		}else{
			for( i=1 ; i <= indent ; i++ ){
				printf("\t") ;
			} ;
			print $0 ;
		} ;

		if( index($0,"{") > 0 ){
			indent++ ;
			if( dbg == 1 ){ print indent | "cat 1>&2" ; } ;
		} ;
	}'
}

PIPE=0

while [ $# -gt 0 ]
do
	case $1 in
		--stream ) PIPE=1 ; shift ;;
		--file )   PIPE=0 ; INPUT="$2" ; shift ; shift ;;
		* ) printf "\n\t Invalid option provided on the command line.  Only available: [ --stream | --file {filename} ]\n\n" ; exit 1 ;;
	esac
done

if [ ${PIPE} -eq 1 ]
then
	prettify
else
	prettify < ${INPUT}
fi

exit
2 Likes

Despite the fact that is was not the actual question, I'd answer it just to satisfy topic's title:

3 Likes

Also, GitHub - jusw85/mozlz4: Decompress / compress mozlz4 files, with precompiled binaries for Windows and Linux

2 Likes